将 C# 转换为 C++

将任何企业级的C#库或控制台应用程序转换为具有完整.NET框架支持的C++等价物。生成的C++库与多种操作系统兼容,包括Linux,MacOS和Windows,确保您的应用程序可以在多个平台上部署。一次性转换数百万行代码,只需最少的人工努力。
请求服务

CodePorting.Translator Cs2Cpp 是一款转译应用程序

它可以用于设置自动转换不断改进的C#代码到C++,以便为两种语言发布相同版本的软件,而不改变API或代码文档。它还可以帮助将C#应用程序和库交付到.NET支持缺失或有问题的平台。

利用我们强大的功能轻松转换 C# 代码

CodePorting.Translator Cs2Cpp是一个源代码到源代码的转换器应用程序,它允许以与原始C#代码相同的方式复制内部类和例程。此外,将C#项目转换为C++后,您可以为任何受支持的目标平台构建它。
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
外部依赖
用手动编写的代码替代无法翻译的依赖项
csharp converter feature
API 保存
C# 代码中使用的特定于语言的构造被转换为最匹配的 C++ 等效项
csharp converter feature
内存控制
在翻译代码中控制弱指针或共享指针,以销毁未使用的对象并中断循环引用

翻译支持库

CodePorting.Translator Cs2Cpp 是一个能将 C# 代码转换为 C++ 的框架。生成的代码提供与原始 .NET 代码相同的 API,并可在翻译后的非托管 C++ 环境中运行。

翻译支持库是一个 C++ 库,其中包含 .NET 类的替代品和一些服务代码。翻译代码最终依赖于该组件。除了 .NET 核心功能外,我们的库还支持 System.Net、System.Drawing、System.XML、System.Security 和其他子系统。翻译支持库将包含在编译后的产品中。如果您计划发布已翻译好的 C++ 代码,建议将翻译支持库 NuGet 包的依赖关系包括在内。
c sharp to cpp conversion scheme

成功翻译为 C++ 的 C# 产品示例

相关文章

支持和学习资源