Converting VB. Net to C# .Net -
this question has answer here:
i'm having trouble converting vb.net c#.net. there datediff() function in code, , i'm having trouble find equivalent function in c#. code in vb below:
'if differnce between , files header date >1 (day,week or year) if datediff(sdateinterval, dfiledate, now) >= 1 return true 'file on write necessary else return false 'file on write not necessary end if
datediff doesn't exist in c#, subtract 2 dates:
datetime date1 = somevalue; datetime date2 = someothervalue; timespan difference = date2 - date1;
so can retrieve, example, difference.totalseconds
.
see msdn page more information.
if want maintain same interval functionality, there's nothing stop referencing microsoft.visualbasic
, using method do: dateandtime.datediff msdn page
Comments
Post a Comment