C# vs VB.NET: Key Syntax Differences Every Developer Should Know
C# and VB.NET are both first-class .NET languages that compile to identical IL (Intermediate Language) and can use all the same libraries, frameworks, and runtime features. Their syntax, however, is significantly different — C# uses C-style braces and semicolons while VB.NET uses keywords and block terminators. If you're working in a codebase that uses both, or migrating from one to the other, this side-by-side reference will speed up the translation.
Convert C# to VB.NET automatically: Paste any C# class or method and get equivalent VB.NET syntax instantly.
Open C# to VB.NET Converter →Table of Contents
File and Namespace Structure
| C# | VB.NET |
|---|---|
using System; | Imports System |
namespace MyApp { } | Namespace MyApp ... End Namespace |
// comment | ' comment |
/* block comment */ | ' no block comment |
Classes and Members
// C#
public class Person
{
public string Name { get; set; }
public int Age { get; private set; }
public Person(string name, int age)
{
Name = name;
Age = age;
}
public string Greet() => $"Hello, {Name}!";
}
' VB.NET
Public Class Person
Public Property Name As String
Public ReadOnly Property Age As Integer
Public Sub New(name As String, age As Integer)
Me.Name = name
Me.Age = age
End Sub
Public Function Greet() As String
Return $"Hello, {Name}!"
End Function
End Class
Control Flow
| C# | VB.NET |
|---|---|
if (x > 0) { } else { } | If x > 0 Then ... Else ... End If |
else if (x == 0) | ElseIf x = 0 Then |
for (int i = 0; i < n; i++) | For i As Integer = 0 To n - 1 ... Next |
foreach (var item in list) | For Each item In list ... Next |
while (condition) { } | While condition ... End While |
switch (x) { case 1: break; } | Select Case x ... Case 1 ... End Select |
Operators and Keywords
| C# | VB.NET |
|---|---|
&& | AndAlso |
|| | OrElse |
! | Not |
== | = |
!= | <> |
null | Nothing |
this | Me |
base | MyBase |
true / false | True / False |
Generics
// C#
List<string> names = new List<string>();
Dictionary<int, string> map = new Dictionary<int, string>();
' VB.NET
Dim names As New List(Of String)()
Dim map As New Dictionary(Of Integer, String)()
Exception Handling
// C#
try { }
catch (IOException ex) { Console.WriteLine(ex.Message); }
catch (Exception ex) when (ex.Message.Contains("timeout")) { }
finally { }
' VB.NET
Try
Catch ex As IOException
Console.WriteLine(ex.Message)
Catch ex As Exception When ex.Message.Contains("timeout")
Finally
End Try
LINQ
LINQ method syntax is nearly identical between C# and VB.NET — the lambda syntax differs slightly:
// C# — method syntax
var adults = people.Where(p => p.Age >= 18).OrderBy(p => p.Name);
' VB.NET — method syntax
Dim adults = people.Where(Function(p) p.Age >= 18).OrderBy(Function(p) p.Name)
LINQ query syntax is also supported in both languages with similar but distinct keyword spellings (from/where/select in C# vs From/Where/Select in VB.NET).
Language Status in 2026: C# vs VB.NET Today
C# 13 (shipped with .NET 9 in November 2024) continues active development with new features including params collections, new lock object semantics, and iterator/async improvements. C# remains Microsoft's primary language for .NET development with a strong yearly release cadence.
VB.NET is in maintenance mode. Microsoft has stated there are no plans to add new language features to VB.NET — it receives only bug fixes and compatibility updates to keep existing codebases running on new .NET versions. New .NET projects should use C#. VB.NET is appropriate only for maintaining existing VB codebases where a full migration is not feasible.
If you are working with a VB.NET codebase and considering migration, see our guide on migrating from VB.NET to C# — including automated conversion tools and common patterns that require manual attention.
