webbiz
Member
- Joined
- Oct 15, 2011
- Messages
- 21
- Programming Experience
- 10+
I'm converting some old code I have in VB6 into C#. I'm new to C# so I'm having trouble finding via search an answer to this question.
Here is the VB6 code snippet:
Dim fJulianDay0 as Double
Dim fJulianDate as Double
Dim iYear as Integer
Dim iMonth as Integer
Dim iDay as Integer
iYear = Year(dDate): iMonth = Month(dDate): iDay = Day(dDate)
fJulianDay0 = CDbl(DateSerial(iYear, 1&, 1&)) + 1.5
fJulianDate = CDbl(DateSerial(iYear, iMonth, iDay)) + 1.5
This is my attempt to convert to C#:
double fJulianDay0, fJulianDate;
int iYear, iMonth, iDay;
iYear = DateTime.Parse(dDate).Year;
iMonth = DateTime.Parse(dDate).Month;
iDay = DateTime.Parse(dDate).Day;
Here is where I am stuck:
Changing...
fJulianDay0 = CDbl(DateSerial(iYear, 1&, 1&)) + 1.5
fJulianDate = CDbl(DateSerial(iYear, iMonth, iDay)) + 1.5
...to C#.
I'm thinking...
fJulianDay0 = (double)(DateTime(iYear, 1, 1)) + 1.5);
...but this gives me an error.
Help please. :ambivalence:
TIA
Here is the VB6 code snippet:
Dim fJulianDay0 as Double
Dim fJulianDate as Double
Dim iYear as Integer
Dim iMonth as Integer
Dim iDay as Integer
iYear = Year(dDate): iMonth = Month(dDate): iDay = Day(dDate)
fJulianDay0 = CDbl(DateSerial(iYear, 1&, 1&)) + 1.5
fJulianDate = CDbl(DateSerial(iYear, iMonth, iDay)) + 1.5
This is my attempt to convert to C#:
double fJulianDay0, fJulianDate;
int iYear, iMonth, iDay;
iYear = DateTime.Parse(dDate).Year;
iMonth = DateTime.Parse(dDate).Month;
iDay = DateTime.Parse(dDate).Day;
Here is where I am stuck:
Changing...
fJulianDay0 = CDbl(DateSerial(iYear, 1&, 1&)) + 1.5
fJulianDate = CDbl(DateSerial(iYear, iMonth, iDay)) + 1.5
...to C#.
I'm thinking...
fJulianDay0 = (double)(DateTime(iYear, 1, 1)) + 1.5);
...but this gives me an error.
Help please. :ambivalence:
TIA