DevTools Logo

C# to VB.NET Converter

C# to VB.NET Converter

Translate a subset of C# — classes, methods, variables, loops — into VB.NET.

C#

client-side
simple subset
no network

Supported: classes, methods (Sub/Function), variable declarations (Dim), if/else if/else, for/foreach/while, and comments. Properties, LINQ, events, and generics need a manual pass — always review.

Examples

Class with a method

Input
public class Calc {
    public int Square(int n) {
        return n * n;
    }
}
Output
Class Calc
    Public Function Square(n As Integer) As Integer
        Return n * n
    End Function
End Class

The class becomes Class/End Class, the method becomes a Function with an As Integer return, and braces become the VB block keywords.

About this tool

The C# to VB.NET Converter rewrites simple C# into VB.NET. Because VB.NET uses keyword-delimited blocks (Class/End Class, Sub/End Sub, If...Then/End If, For/Next), the converter tracks brace nesting and maps each closing brace to the matching End keyword, treating if/else if/else as a single block.

Methods become Sub (void) or Function with an `As RetType` clause, variable declarations become `Dim`, and `for`/`foreach`/`while` become their VB equivalents. The conversion runs entirely client-side — nothing is uploaded. It targets a subset; properties, LINQ, events, and generics need a manual pass.

How to use this tool

  1. Paste C# code

    Load the sample or paste a class with methods and control flow.

  2. Inspect the VB.NET

    The output pane shows the converted code with correct block keywords and indentation.

  3. Copy and finish

    Copy the result and review any unsupported constructs the converter left in place.

Use cases

Cross-language port

Move a C# class into a VB.NET project as a starting point for finishing by hand.

Reading C# as VB.NET

Understand a C# snippet by seeing its VB.NET equivalent side by side.

Common mistakes

Mistake:Expecting LINQ or properties to convert.

Fix:Those are outside the subset — convert the structure, then add LINQ/properties by hand.

Mistake:Missing the End keywords.

Fix:Every block opener needs its closer (End Class, End Sub, Next, End If); the converter emits them from the brace stack.

Frequently asked questions

What C# features are supported?

Classes, methods (Sub and Function), variable declarations (Dim), if/else if/else, for, foreach, while, and comments. Properties, LINQ, events, and generics need a manual review pass.

How are braces handled?

VB.NET uses keyword blocks (Class/End Class, If...Then/End If, For/Next) instead of braces. The converter tracks brace nesting so each closing brace maps to the right End keyword, and treats if/else if/else as one block.

Does it run offline?

Yes. Parsing and conversion happen client-side in your browser — nothing is uploaded.

References & standards