tags:

views:

71

answers:

3

hello i want to add some .h and .cpp files in c# to get the c++ functionality in c# i want to use tha code directly with out making any dll file.

can i do so if yes the how can i do this.

thanx in advance

+3  A: 

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.

Kate Gregory
A: 

No. You can't.

You'll either have to migrate the code to C# or comiple the C++ code down into a DLL and then call that from C#.

Justin Niessner
+1  A: 

If you already have the code in c++ the best option is to use C++/CLI where you can include .h and .cpp files and reference the compiled dll from your c# project.

Giorgi