Let's say I have a library with a C function, which was compiled using gcc, is there any way to call this function in C #, if so what would its performance compare to the same function created in C #?
Let's say I have a library with a C function, which was compiled using gcc, is there any way to call this function in C #, if so what would its performance compare to the same function created in C #?
First you have to export the function in your C.
For example
//Exemplo.dll
extern "C" __declspec(dllexport) double funcaoExemplo (int valor)
{
//código
}
and in your C # you should use DllImport
[DllImport("Exemplo.dll")]
private static extern double funcaoExemplo (int valor);
public double Teste (int value)
{
return funcaoExemplo(value);
}
In terms of performance, C has an advantage over this, since C is a compiled language, whereas C # is a semi-compiled language, depending on the framework .