在C#开发环境中使用C ++ [英] using of C++ in C# development environment

查看:84
本文介绍了在C#开发环境中使用C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我使用VS 2008 C#Express.
我有一个用C#编码的项目.我的项目中也需要C ++代码段.

可以说我是否可以在C#开发环境中使用C ++源代码.如果可能的话,我该如何实现呢?

预先感谢,

Hasan

Hi all,

I use VS 2008 C# Express.
I have a project coded in C#. I also need C++ code snippets in my project.

Could one say me whether using C++ source codes in C# development environment is possible. If possible, How can I achieve this?

Thanks in advance,

Hasan

推荐答案

所有问题都在"Express"中.
如果安装它,则可以选择Visual Basic Express,Visual C ++ Express,Visual C#Express,Visual Web Developer Express,Windows Phone Express.如果我没记错的话,您不能在同一台计算机上同时安装两个或多个这些环境变体.

这将使得使用两种语言进行开发成为可能,但是非常不方便:要么使用单独的计算机,要么重新安装,然后一直强制执行:(.

还有一个选择:您可以只安装C ++,而C#编程不需要环境,或者可以使用 SharpDevelop .

当您完成(例如)C ++项目时,例如在C#环境中使用它就不会出现问题:您仅以可执行形式复制已编译的程序集,然后在C#项目中引用它.但是对于使用两个不同环境进行的增量开发...

...这将非常不便.我永远不会打扰.
All the problems are in "Express".
If you install it, you choose between Visual Basic Express, Visual C++ Express, Visual C# Express, Visual Web Developer Express, Express for Windows Phone. If I''m not much mistaken, you cannot install two or more of these variants of the environment on the same computer at the same time.

This would make development using two language possible but quite inconvenient: either using separate computers or re-installing then back and force all the time :( .

There is one more option: you can install just C++, and C# programming does not need environment, or you can use SharpDevelop.

When you complete your (for example) C++ project, using it in, say, C# environment will not be a problem: you copy just the compiled assembly, in executable form, and later reference it in your C# project. But as to incremental development using two different environments...

...This would be extremely inconvenient. I would not bother, ever.


是的,有可能.您应该将C ++代码封装在一个库项目(dll)中,并在您的C#项目中引用该dll.希望对您有所帮助.
Yes it is possible. You should encapsulate C++ code in a library project (dll) and reference this dll in your C# project. Hope this helps.


通常可以以最少的更改将C ++更改为C#.最困难的更改可能与宏预处理和内存有关.您可能需要使用unsafe关键字.您可能还需要将C ++中的::更改为.在C#中
C++ can usually be changed to C# with minimal changes normally. The most difficult changes might be related to macro preprocessing and memory. You might need to use the unsafe keyword. You may also need to change :: in C++ to . in C#


这篇关于在C#开发环境中使用C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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