The developer's resource for computer interfacing, especially USB, serial (COM) ports, mass storage, and embedded networking. (Formerly

Home > Articles > Visual C# for Visual Basic Programmers

Visual C# for Visual Basic Programmers

Visual C# is a programming language that has roots in C but is object oriented like Java. Many keywords, symbols, and structures are borrowed from C.

If you’re a Visual Basic programmer, please don’t despair. Over time, Visual Basic and Visual C# have grown much closer, and switching between languages is much less of a burden than it once was. Both languages support the .NET Framework’s classes, and both can use Visual Studio’s programming environment.

Here are variables declared in Visual Basic:

Dim horizontalSpacing As Int32 = 16
Dim statusMessage As String = "OK"

And here are the same variables declared in Visual C#:

Int32 horizontalSpacing = 16;
String statusMessage = "OK"; 

Each declaration contains the same information. The differences include word order, Visual Basic’s added Dim...As, and Visual C#’s line-ending semicolons.

In general, Visual C# tends to prefer symbols for operations where Visual Basic uses words. Here are some logical operators in Visual Basic and Visual C#:

Logical Operation





Visual Basic





Visual C#





Partner Links

Of course there are fine points that may trip you up at first. For example, when declaring an array’s size in Visual Basic, you specify the upper bound, while in Visual C#, you specify the number of elements. Here is a 4-byte array in Visual Basic:

Dim buffer As Byte() = New Byte(3)

and here is the same array in Visual C#:

Byte[] buffer = new Byte[4];

The resulting arrays are identical and support indexes 0–3.

If you get stuck on how to do something in C#, code converters such as the one at do a pretty good job of converting code snippets from Visual Basic to Visual C#.