I have been tasked with converting an old VB6 program to to C#. One function I have been having trouble porting over is the calculation of a birthdate from a filed that was read from a binary file:
.BirthDate = CDate((CLng(recPatient.birthDateByte2) * 256) +
(recPatient.birthDateByte1 + 366))
The only function I could find that is remotely similar is:
DateTime BirthDate = DateTime.ToDateTime((long)recPatient.birthDateByte2) * 256)
+ (recPatient.birthDateByte1 + 366));
However ToDateTime(long)
just returns an InvalidCastException
.
Now I can build the string manually but I can not find any documentation anywhere on VB6's CDate(long)
.
What am I doing wrong?