p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=138)
-   -   Convert a vb.net line to C# (http://p2p.wrox.com/showthread.php?t=74308)

Nishapd May 8th, 2009 09:07 AM

Convert a vb.net line to C#
Can anyone help me to convert following vb.net line to C# ?
I am trying to do it following way but somehow it is not working.


If dtPmtTransmitDate = System.DateTime.MinValue Or dtPmtTransmitDate = #11:00:00 PM# Then
strPendProcessDate = Format(dtPendProcessDate, "MMddyyyy")


if (dtPmtTransmitDate == System.DateTime.MinValue || dtPmtTransmitDate == 23:00:00) {
strPendProcessDate = string.Format("MMddyyyy",dtPendProcessDate);
else { }

philip_cole May 8th, 2009 12:45 PM

Hi, you've got 2 issues.

1: In the If condition, the date value, 23:00:00 you are checking against should be in ""s, otherwise you will get a syntax error.

2. The String.Format bit is not quite right. The easiest way is to use the ToString method in the DateTime object to get the correct format - see MSDN:

strPendProcessDate = dtPendProcessDate.ToString("MMddyyyy");

All times are GMT -4. The time now is 09:48 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.