C# and VB.NET comparison

  • Thread starter Thread starter Frank McCown
  • Start date Start date
F

Frank McCown

I've created a quick reference comparison of C# and
VB.NET that you might find useful. I couldn't find
anything like it on the web and so I made my own.

http://www.harding.edu/USER/fmccown/WWW/vbnet_csharp_compa
rison.html

It doesn't cover every area of the languages, just those
features most frequently used.

I also created a Java and C# comparison:

http://www.harding.edu/USER/fmccown/WWW/java_csharp_compar
ison.html

I'd be thankful for any suggestions you may have on ways
to improve the comparisons.

Thanks,
Frank
 
Frank McCown said:
I also created a Java and C# comparison:

http://www.harding.edu/USER/fmccown/WWW/java_csharp_compar
ison.html

I'd be thankful for any suggestions you may have on ways
to improve the comparisons.

You've fallen into the "objects are passed by reference" trap for Java
and C#. Please read
http://www.pobox.com/~skeet/csharp/parameters.html
I can't remember offhand whether or not Java is getting variable
parameter lengths in 1.5, but it may well be.

Picky things:

o Constants in Java are usually declared to be static. (It's implicit
in C#)

o Under enumerations, I believe the preferred order for modifiers is
"public static final int", although it doesn't matter too much. It
might also be worth mentioning that Java is getting enumerations in
1.5.

o Under arrays, in Java you can write:
int[][] x = new int[5][3];
but you can't do the same thing (with jagged arrays) in C#.

o Under foreach, it may be worth mentioning that Java is getting
foreach (in the form "for x : collection") in 1.5. The usual equivalent
of foreach would be done using an Iterator though.

o Under "choices", your code would give a warning under Java 1.4 (due
to the fallthrough).

o Under exception handling, not only is the argument itself entirely
optional in C#, but you can also get rid of *just* the variable name.
It would also be worth mentioning that C# (and .NET in general) doesn't
have checked exceptions.

o Under namespaces, your import statement is incorrect in Java - it
should either be "import Harding.Compsci.Graphics.*;" or
"import Harding.Compsci.Graphics.ClassName;". You might also want to
change the package name to "harding.compsci.graphics" to follow Java
conventions for the Java version.
 
Jon-

Thanks for your input. I will make some updates to the
Java/C# comparison soon.

Frank
 
Back
Top