Mike_R Posted January 7, 2004 Posted January 7, 2004 It is my understanding that C# and VB have been made essentially 98% compatible, maybe 100% compatible with each other... But one issue sticks out with me... If a Boolean value or expression returning 'True' coerces to -1 in VB and +1 in C#, how does this work?? I've tested VB.Net and confirmed that MessageBox.Show(CLng(True).ToString) returns -1, as it did in VB 6.0... But I don't have VS.Net, so I can't test it in C... Can someone let me know how C#.Net handles this? And how any discrepancy is rectified?? Thanks in advance :), Mike Quote Posting Guidelines Avatar by Lebb
samsmithnz Posted January 7, 2004 Posted January 7, 2004 It is my understanding that C# and VB have been made essentially 98% compatible, maybe 100% compatible with each other... But one issue sticks out with me... If a Boolean value or expression returning 'True' coerces to -1 in VB and +1 in C#, how does this work?? I've tested VB.Net and confirmed that MessageBox.Show(CLng(True).ToString) returns -1, as it did in VB 6.0... But I don't have VS.Net, so I can't test it in C... Can someone let me know how C#.Net handles this? And how any discrepancy is rectified?? Thanks in advance :), Mike I THINK that 0 is false, and everything else is true. Quote Thanks Sam http://www.samsmith.co.nz
*Experts* Bucky Posted January 8, 2004 *Experts* Posted January 8, 2004 Don't use the old conversion methods of VB6, ones such as CLng, CStr, CDbl, etc. Instead, use the shared methods of the Convert class. MessageBox.Show(Convert.ToInt32(True).ToString()) Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
dragon4spy Posted January 8, 2004 Posted January 8, 2004 Can you point me about where all old functions reside in? Just to be aware of 'em, cos i'm afraid that i'll use them. Quote Don't judge a man by his look. Don't judge a book by its cover. :D
*Experts* Bucky Posted January 8, 2004 *Experts* Posted January 8, 2004 Well the conversion functions mentioned above are not actually in the framework, they're VB-specific keywords. As a general rule, don't use any VB6 functions. Anything with the same name as VB6 is probably part of the "Visual Basic Run-Time Library Members", which you should stay away from. Yes, it takes some getting used to, but yes, it helps in the end. Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
*Gurus* divil Posted January 8, 2004 *Gurus* Posted January 8, 2004 True is equal to 1 in C# and -1 in VB. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.