Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may not have to convert the code. </p> <p>link.exe, part of the C++ compiler tools, is able to include both C++ and C# code in the same assembly. The C++ bit can include a mixture of managed and unmanaged code. You first have to compile the C# code to a .netmodule with command line switches of the C# compiler (csc.exe), and then you can use link.exe to compile it into an assembly with C++ code. It's been a while since I've created a mixed language assembly so apologies if the details are not 100%, but search for the above terms and you will find a way to do it.</p> <p>I seem to remember that the key part is remembering that the C++ compiler is more advanced than the others and so can consume C#/VB netmodules, but not the other way round. I found that the advantage of compiling into a single assembly rather than one referencing another is that types inside each part of the single assembly can cross-reference each other. By having references between two separate assemblies the type awareness relationship has to be hierarchical.</p> <p>There is also the <a href="http://msdn.microsoft.com/en-us/library/chfa2zb8%28v=vs.100%29.aspx" rel="nofollow">unsafe</a> keyword in C#, which allows C++-ish style pointers to be used within sections of a C# code file, and turns off array bounds checking. There are disadvantages of this that may or may not matter depending on your usage scenario.</p> <p>Personally I found that running some calculation-intensive code was 20x quicker in the C++ compiler compared to C#, after I had optimised it using the pointers available in C++, which was worth the effort in my case.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload