Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 8th, 2009, 09:07 AM
Authorized User
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.


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 { }
Old May 8th, 2009, 12:45 PM
Friend of Wrox
Join Date: Sep 2005
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts

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");

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

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