Convert C# to C++

Translate any enterprise-level C# library or console application to its C++ equivalent with full support for the .NET Framework. The resulting C++ library is compatible with a wide range of operating systems, including Linux, MacOS, and Windows, ensuring that your application can be deployed on multiple platforms. Translate millions of lines of code at once with minimal manual effort.

CodePorting.Translator Cs2Cpp is a transpiler application

It can be use to set up automated translation of continuously improving C# code to C++ in order to release the same version of the software for both languages without changing the APIs or code documentation. It can also help in delivering C# applications and libraries to platforms where .NET support is either absent or is problematic.

Effortlessly Convert C# Code with Our Powerful Features

CodePorting.Translator Cs2Cpp is a source code to source code transpiler app, allowing the reproduction of internal classes and routines in the same way as they are implemented in the original C# code. Moreover, after translation the C# project to C++, you can build it for any of the supported target platforms.
public void EnclosedWhile(int max1, int max2)
{
	int number1 = 0;
	while (number1 < max1)
	{
		int number2 = 0;
		while (number2 < max2)
		{
			Console.WriteLine(number1 + number2);
			++number2;
		}
		++number1;
	}
}
void WhileStatements::EnclosedWhile(int32_t max1, int32_t max2)
{
	int32_t number1 = 0;
	while (number1 < max1)
	{
		int32_t number2 = 0;
		while (number2 < max2)
		{
			System::Console::WriteLine(number1 + number2);
			++number2;
		}
		++number1;
	}
}
public class ClassProperties
{
	public string PublicProperty
	{
		get { return mPublicPropertyField; }
		set { mPublicPropertyField = value; }
	}

	private string mPublicPropertyField;
}

class ClassProperties : public System::Object
{
    public:
        System::String get_PublicProperty();
        void set_PublicProperty(System::String value);

        ClassProperties();

    private:
        System::String mPublicPropertyField;
};
public void BreakEnclosedForeach(int[][] values, int max)
{
	foreach (int[] row in values)
	{
		if (row.Length == 0)
		{
			break;
		}

		foreach (int value in row)
		{
			Console.WriteLine(value);
			if (value > max)
			{
				break;
			}
		}
	}
}

void BreakStatements::BreakEnclosedForeach(System::ArrayPtr<System::ArrayPtr<int32_t>> values, int32_t max)
{
    for (System::ArrayPtr<System::ArrayPtr> row : values)
    {
        if (row->get_Length() == 0)
        {
            break;
        }

        for (int32_t value : row)
        {
            System::Console::WriteLine(value);
            if (value > max)
            {
                break;
            }
        }
    }
}
using System.Threading;

class LambdaTest
{
    public void TestMPMM_1()
    {
        var a = 0;
        new Thread(() =>
        {
            var b = a;
        });
    }
}
#include <system/threading/thread.h>
#include <system/details/lambda_capture_holder.h>
#include <functional>
#include <cstdint>

void LambdaTest::TestMPMM_1()
{
    System::Details::LambdaCaptureHolder<int32_t> _lch_a = 0;
    int32_t &a = _lch_a.GetCapture();
    System::MakeObject<System::Threading::Thread>(static_cast<System::Threading::ThreadStart>(static_cast<std::function<void()>>([_lch_a, &a]() -> void
    {
        int32_t b = a;
    })).template AddHeldVariable<System::Threading::ThreadStart>("a", a));
}
csharp converter feature
External Dependencies
Substitute the manually written code as a replacement for the dependency which is not available for translation
csharp converter feature
API Preservation
The language-specific constructs used in the C# code are translated into the best-matched C++ equivalents
csharp converter feature
Memory Control
Control weak or shared pointers in the translated code to destroy unused objects and to break loop references

Translator support library

CodePorting.Translator Cs2Cpp is a framework capable of translating C# code to C++. The resulting code provides the same API that the original .NET code had and can run in the translated unmanaged C++ environment.

The translator support library is a C++ library with substitutes for .NET classes and some service code. The translated code is ultimately dependent on this component. Along with .NET core features, our library supports the System.Net, System.Drawing, System.XML, System.Security, and other subsystems. The translator support library will be included in the compiled product. If you plan to distribute your translated C++ code, it is recommended to include the dependency on the translator support library NuGet package.
c sharp to cpp conversion scheme

C# to C++ Conversion Tutorial

Examples of C# products successfully translated to C++

Related News

Related Articles

Support & Learning Resources