Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 8th, 2009, 09:07 AM
Authorized User
Points: 241, Level: 4
Points: 241, Level: 4 Points: 241, Level: 4 Points: 241, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2009
Posts: 52
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.

vb.net

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


C#

if (dtPmtTransmitDate == System.DateTime.MinValue || dtPmtTransmitDate == 23:00:00) {
strPendProcessDate = string.Format("MMddyyyy",dtPendProcessDate);
}
else { }
  #2 (permalink)  
Old May 8th, 2009, 12:45 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

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:
Code:
strPendProcessDate = dtPendProcessDate.ToString("MMddyyyy");
Phil
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to implement ruler line in vb.net windows application dilipmca04 Pro Visual Basic 2005 0 April 17th, 2009 11:32 AM
VB.NET 2003 Appendix B convert to VB 2008 Express Edition brucechess BOOK: Beginning VB.NET Databases 10 February 5th, 2009 12:52 PM
convert dsr file from vb to vb.net Shashi001 VB Components 1 September 22nd, 2006 12:24 PM
Change line in VB.net Dinesh22 VB.NET 2002/2003 Basics 2 January 16th, 2004 02:27 PM
Help - Convert from C# to VB.Net CrazyLegsCooper VS.NET 2002/2003 1 July 20th, 2003 10:06 AM



All times are GMT -4. The time now is 07:44 PM.


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