PROWAREtech

articles » archived » dot-net » csharp-versus-vb-net

.NET: C# versus VB.NET

A quick guide to the differences between C# and VB.NET.

This article is written for the business manager trying to decide which language he wants his project written in.

C# (pronounced C sharp) and VB.NET are both fully object oriented languages with the huge .NET library at their disposal. The key differences between the two languages are that VB is a verbose one designed to be easily read and understood, particularly for beginners, while C# is more cryptic, designed to be like the C/C++ programming language thereby leveraging the huge number of C/C++ programmers today. The C programming language was developed to be short and terse because, when it was developed in the 1970's, its parser would run faster and use less memory with its syntax. With today's computers, this is not a concern.

Both the C# and VB.NET languages are compiled into the same Microsoft Intermediate Language (MSIL) byte code and then into the same machine code by the Common Language Runtime (CLR). Contrary to popular belief, neither language compiles into binary code that executes any faster than the other.

A C/C++ programmer may find it better to use VB.NET when working with the .NET library because the little differences between C/C++ and C# are enough to make a programmer crazy. Differences like passing parameters by reference and the use of pointers as well as the differences regarding arrays. VB.NET arrays are an even bigger mess as well as its FOR loop. C# sometimes seems like a marriage of C++, Java and JavaScript due to similar objects and syntax. So, for a website, it may be easier to work in a VB.NET mindset when programming server-side with the .NET library, in a JavaScript mindset when programming client-side for the browser, and in a C/C++ mindset when doing lower level programming, like systems programming. On the otherhand, it may just be easier to use one C-like language throughout as VB.NET may prove to be too different. There is no simple answer here. C/C++, JavaScript and C# all share a similar C like syntax. It is important to choose a language that will be easy to find programmers for.

C++ was too complex and VB was too basic to work with Microsoft's new .NET platform so they came out with C# for programmers with a computer science background — who predominately used C++ — and VB.NET for those who focused on end-user applications (VB6 programmers).

A project can mix languages by compiling one into binaries. So, if two programmers are working on the same project then they do not neccesarily have to use the same language.

Finally, while VB.NET is more forgiving and does more with less time, it is slowly being outed by C#. This is something to consider for the future as more and more computer books have C# examples only. Check resources in the area to see what is available.

Comparing VB.NET and C#, programmers will find:

C# Equivalent
VB.NET Equivalent
this
Me
static
Shared
for(int i = 0; i < 3; i++)
{
	;
}
Dim i As Integer
For i = 0 To 2

Next i
not needed
AddressOf
abstract
MustOverride
int[] intArray = {0};
intArray[0] = 1;
Dim intArray(0) As Integer
intArray(0) = 1
Form frm = new Form();
int i;
Dim frm As New Form
Dim i As Integer
no equivalent
ReDim
no equivalent
IsNumeric
base
MyBase
void
Sub
null
Nothing
System.DBNull.Value.Equals(expression);
IsDbNull(expression)
Button.Click += new EventHandler(Button_Click);
AddHandler Button.Click, AddressOf Button_Click
no equivalent
\
&
And
|
Or
&&
AndAlso
||
OrElse
struct
Structure
int i, j, x;
Dim i As Integer, j As Integer, x As Integer
var cx;
Dim cx


This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.
CLOSE