Differences Between VB and C#
Other than the obvious syntax differences
between VB and C# which are handled by automatic conversion from VB
to C# and C# to VB, there are some important differences in the
features between the two languages:
- C# allows 'unsafe' code, or pointer manipulation.
- C# allows assignments embedded in expressions (e.g., if ((x = y.Value) == 2)).
- C# has anonymous methods and a more
flexible lambda operator. VB10 will include complete
equivalents for all C# lambda scenarios.
- C# has the useful conditional ternary operator (?:). The VB
IIf function is not a good substitute since the arguments
must all be evaluated, however VB9 has the If ternary
operator which has identical behavior to the C# operator.
- VB allows methods with optional parameters. C#4 includes this feature.
- VB allows using named parameters when calling methods. C#4 includes this feature.
- VB allows types within interfaces.
- VB has the very flexible Select construct (much more flexible than the C# switch).
- VB has the When filter for catch block headers (no equivalent exists in C#).
- VB has a special intuitive syntax for XML literals.
Note that although VB allows late binding,
you can achieve the same effect via reflection in either language
with a minimal amount of code.
If you need to convert between VB and C# and
you are depending on the results being reliable and accurate, then
you will want to have
Instant C#, the best VB to C# converter, or
Instant VB, the best C# to VB converter, at your fingertips.