Convert code from VB.NET to C# (and vice versa) using Roslyn - all free and open source:
- Visual Studio extension
- Online snippet converter
- Command line
dotnet tool install ICSharpCode.CodeConverter.codeconv --global(Requires VS2019+ installed)
- Nuget library (this underpins all other free converters you'll find online)
Visual Studio Extension
Adds context menu items to convert projects/files between VB.NET and C#. See the wiki documentation for advice / help using it.
Download from Visual Studio Marketplace (Use VS 2019+)
- Flexible: Convert a small selection, or a whole solution in one go, in either direction.
- Accurate: Full project context (through Roslyn) is used to get the most accurate conversion.
- Safe: Conversion runs entirely locally - your code doesn't leave your machine.
- Completely free and open source GitHub project.
- Integrated: Uses the Output window to show conversion progress / summary.
- Actively developed: User feedback helps us continuously strive for a more accurate conversion.
Let us know what needs improving. If you want to get involved in writing the code yourself, even better! We've already had code contributions from several first time GitHub contributors, so don't be shy! See Contributing.md for more info.
Currently, the VB -> C# conversion quality is higher than the C# -> VB conversion quality. This is due to demand of people raising issues and supply of developers willing to fix them. This seems to be because the use cases for two directions tend to differ considerably.
Visual Basic .NET is slowly dying. It has support for some project types on .NET 5, but won't be getting new features according to the .NET Team Blog. Hence the main use case for:
- VB->C#: moving whole projects
- C#->VB: help incorporate snippets from stack overflow into existing VB codebase, or to help learning one language from the other
Other ways to use the converter
- Latest CI build (potentially less stable):
- See latest build
- Uninstall current version, click on a build and download/install the VSIX file at the bottom of the page
- Integrating the NuGet library
Building/running from source
- Ensure you have .NET Core SDK 6.0
- Open the solution in Visual Studio 2022+ (Community edition is sufficient)
- To run the website, set CodeConverter.Web as the startup project
- You will need Node (LTS) 16.* (node 17 introduces a breaking change causing ERR_OSSL_EVP_UNSUPPORTED)
- To run the Visual Studio extension, set Vsix as the startup project
- A new instance of Visual Studio will open with the extension installed
A spiritual successor of the code conversion within SharpDevelop and later part of Refactoring Essentials, the code converter was separated out to avoid difficulties with different Visual Studio and Roslyn versions.