Transition from C# to VB.NET

  • Thread starter Thread starter Icon Iconoclast
  • Start date Start date
a Couple of hours....then just hit n miss on some syntax
look at inherit differences
For the most part if u know c#, VB. NET is not a problem...
Watch them Semi colons

Dave
 
Just be aware that there are some fairly insiduous gotcha's.

The behavior of the 'Handles' clause in VB is different than the behavior of
event wireups in C# (but 'AddHandler' is identical).

Integer division: You need to use '\' in VB - otherwise your results will
change.

Also, if you think the following are equivalent - they're not:
C#: VB - not quite:
null Nothing (VB's 'Nothing' applies also to
value types)
typeof TypeOf (C# 'typeof' -> VB 'GetType')
is Is (C# 'foo is' -> VB 'TypeOf foo
Is')
== = (only equivalent for value types)

These are just a few, but there are many others... so I think a few hours or
days to make the transition is a bit idealistic. You'll be coding VB within
a few hours, but you'll be sorting out the syntax nuances for weeks or months.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI
 
Icon said:
If I already know C#, how long would it take me to learn VB.NET?

Not long.

And if you get stuck you can always cheat: write the code
in C# and convert it to VB.NET and study the output !

Arne
 
One thing that is different in VB is defining arrays.

(1) Dim a As String() = New String(10) {}

is not equivalent to

(2) String[] a = new String[10];

in c#

In VB you specify the last index of the array not the length. So the VB
example gives you an array of 11 elements not 10.
 
Right - that's one of the most common mistakes when developers are switching
between languages.
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI


Jan Obrestad said:
One thing that is different in VB is defining arrays.

(1) Dim a As String() = New String(10) {}

is not equivalent to

(2) String[] a = new String[10];

in c#

In VB you specify the last index of the array not the length. So the VB
example gives you an array of 11 elements not 10.






David said:
Just be aware that there are some fairly insiduous gotcha's.

The behavior of the 'Handles' clause in VB is different than the behavior of
event wireups in C# (but 'AddHandler' is identical).

Integer division: You need to use '\' in VB - otherwise your results will
change.

Also, if you think the following are equivalent - they're not:
C#: VB - not quite:
null Nothing (VB's 'Nothing' applies also to
value types)
typeof TypeOf (C# 'typeof' -> VB 'GetType')
is Is (C# 'foo is' -> VB 'TypeOf foo
Is')
== = (only equivalent for value types)

These are just a few, but there are many others... so I think a few hours or
days to make the transition is a bit idealistic. You'll be coding VB within
a few hours, but you'll be sorting out the syntax nuances for weeks or months.
 
Back
Top