tags:

views:

141

answers:

1

How can I compile C code for use in .NET?

There is a game that written in C; how can I convert it to .Net code or use some parts of it?

+7  A: 

You can't use C code directly within .NET.

You have a couple of options:

  1. Compile the C code into a dynamic link library, and use P/Invoke in order to call it from your .NET program.

  2. Port the C code to .NET.

  3. Wrap the C code using C++/CLI (making a mixed mode assembly), and use these from within your other .NET language of choice.

Reed Copsey
Actually, there is a C to CIL compiler.
SLaks
@SLaks: Have you ever used it for anything significant? It failed on me the only times I've tried ;)
Reed Copsey
I've never tried it.
SLaks
Hi thank U :XIS there any sample or Training For these ways?on of them is better?what is way two mean?
shaahin
+1 Nice succinct answer. Though I doubt the poster will be able to use it...
Byron Whitlock
Never mindthe poster will try and working hard.y help him instead saying ..... :|
shaahin
why topic closed?
shaahin
@shaahin: The topic was closed because your question wasn't written very well. Better written questions get better responses. As for the best option above - all three have advantages and disadvantages... It's hard to label one as better than the other, at least without more information.
Reed Copsey
Ok Tnx :)I'll carefully.
shaahin