Jump to content


Tips for anyone converting C# code to VB.NET


2 replies to this topic

#1 daviangel

    New Member

  • Members
  • PipPip
  • 15 posts

Posted 05 December 2006 - 09:25 AM

I just wanted to post some stuff I have come across lately porting my C# code over to VB.NET:

use quick find replace to remove all ; at end of statements
use shared instead of static
use single instead of float
use directcast() to cast objects from one type to another
use IIF for C# conditional operator
use nothing instead of null
use Imports instead of Using
use () instead of [] for arrays
use ' for comments
use ''' for XML comments
sub new() for constructor instead of class name


and the weirdest thing I have come across is using [] around words that are keywords in VB so they don't confuse VB compiler.
Like [enum]
I always wondered what the hell people were using those around certain words
well that's all I can think of right now off the top of my head

#2 someone13

    New Member

  • Members
  • PipPip
  • 17 posts

Posted 05 December 2006 - 09:56 AM

Just to let you know, SharpDevelop comes with a built-in C# to VB.NET (and vise-versa) code converter. I haven't used it so I don't know how good it is.

#3 spoulson

    New Member

  • Members
  • Pip
  • 6 posts

Posted 02 January 2007 - 03:59 PM

Since the CLR is multi-language friendly, what is the point in converting working code?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users