Alex Rivera | Logout

can i add .h and .cpp files in a c# project?

Asked 2010-06-03T12:22:07.773
13

I want to add some .h and .cpp files to a C# project to get the C++ functionality in C#. I want to use the code directly without making a dll.

Can i do so? How?

Edit
Report

1 Answer

8

No you cannot. If the amount of code is small, you can write a C# class and paste pieces of the C++ code into it so that you essentially ported that class into C#. Obviously this won't work if you're using a language feature or library function that is not in C#. Alternatively you need to compile your C++ code into something executable (either a native DLL, ideally C-style flat functions, or a managed assembly) so that you can call it from your C# code.

answered 2010-06-03T12:24:28.593

Your Answer