Question

So I have a server in c# and im trying to optomize it in general
https://www.quora.com/How-do-I-call-a-C-function-from-C-code

So I saw that I can call function wrote in c++ in a c# project
so is it worth to rewetie the functions in c++ and call them in c# ?

also If i did that running the server in linux will stay the same using

dotnet run command or I have to do extra things ?

Thanks,
Quora
Answer (1 of 5): To call a C++ function from C# code, you can use Platform Invoke (P/Invoke). Platform Invoke is a feature of .NET that allows managed code to call unmanaged code, such as C++ code.

Here are the general steps to call a C++ function from C# code using P/Invoke:

  1. Define the C++ ...
Was this page helpful?