Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posting Guidelines

 

Avatar by Lebb

Posted
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.

  • *Experts*
Posted

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())

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted
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.
Don't judge a man by his look. Don't judge a book by its cover. :D
  • *Experts*
Posted

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.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...