将C ++代码转换为C# [英] Convert C++ code to C#

查看:645
本文介绍了将C ++代码转换为C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好程序员

我想要(如果存在)一个程序将c代码自动转换为c#。如果没有程序这样的请求可以告诉我如何制作一个简单的程序,从哪里可以开始我必须阅读的文件



谢谢

最好的问候



我尝试过:



我在网上搜索并获得这个程序(CxxCavaConverter),但它不是应用程序,它只是代码库。

hello programmers
I want (if exist) a program that convert c code to c# automatically. if there is not program such that pleas can you advise me how to make simple one, from where can i start what document i have to read

thanks
best regards

What I have tried:

I was make search in web and get this program (CxxCavaConverter) but it is not application it is just library for code.

推荐答案

不要。

虽然C和C#非常相似,但它们在基本层面上非常非常不同:C#是基于OOP的,而C绝对不是!虽然语法看起来非常相似,但C#是基于参考的,并且努力防止你使用指针(根本不是同一个东西),其中C是基于堆栈的,并且广泛使用指针。

转换任何C代码(除了琐碎的代码片段)最多会产生错误的C#代码 - 而单独的琐碎片段不需要任何真正的转换帮助!

使用C代码作为一个基础,并设计C#代码以在C#OOPs环境中执行相同的功能。你会得到更好的结果,可能会更快!
Don't.
Although C and C# look very similar, they are very, very different at a fundamental level: C# is OOPs based, and C is most definitely not! And although the syntax looks very similar, C# is heavily reference based, and tries hard to prevent you using pointers (which aren't the same thing at all) where C is heavily stack based, and uses pointers extensively.
Converting any C code (other than trivial snippets) is going to produce bad C# code at best - and trivial snippets alone don't need any real help to convert!
Use the C code as a basis, and design the C# code to do the same function but within a C# OOPs environment. You'll get a much better result, and probably a lot quicker!


不要费心转换代码。



迁移到C#的唯一原因是访问.NET框架。将代码编译为C ++ / CLI,即C ++ for .NET。您可以与其他.NET项目(包括C#或VB.NET)结合使用。
Don't bother converting the code.

The only reason to move to C# is access to the .NET framework. Compile the code as C++/CLI which is C++ for .NET. You can combine with other .NET projects (including C# or VB.NET).


这篇关于将C ++代码转换为C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆