␡
- Introduction
- Creating a Simple SharpDevelop Project
- Inserting the C++ Code into the C# Project
- Rules for Migrating C++ to C#
- Other Required Changes
- Putting It All Together
- Other Reasons for Calling C++ Code from C#
- Conclusion
- Additional Reading
Like this article? We recommend
Other Reasons for Calling C++ Code from C#
Beyond the need to bridge legacy C++ code into the .NET/C# domain, there are other reasons for trying to access code written in C or C++:
- One obvious example is performance. A specific block of C/C++ code may simply be faster than comparable C# code. This is reminiscent of the old arguments about Java and C++.
- In certain situations, there may be a strong case for needing direct access to memory outside the management of the .NET Common Language Runtime.
- Another time you may need pointers is when you have to call in to DLLs that contain C-based functions. The same may be true for COM server code.
One final point with regard to legacy languages concerns embedded devices. Increasingly, C++ is the language of choice for these platforms. If you want to bridge between such devices and the C# world, you now have a few tools for making a start.