T
Tim Johnson
I thought passing an int* to a C-function via P/Invoke ought to be done like
this:
static extern void MyFunc( [Out] Int32 myvalue);
Int32 val=0; //Init required to silence warning
MyFunc(val);
But this throws an exception at runtime. However this works:
static extern void MyFunc( out Int32 myvalue);
Int32 val; //Note no initialization required!
MyFunc(out val); //out required here too or won't compile!
What's the diff and when is one correct vs. the other?
this:
static extern void MyFunc( [Out] Int32 myvalue);
Int32 val=0; //Init required to silence warning
MyFunc(val);
But this throws an exception at runtime. However this works:
static extern void MyFunc( out Int32 myvalue);
Int32 val; //Note no initialization required!
MyFunc(out val); //out required here too or won't compile!
What's the diff and when is one correct vs. the other?