DotNet - What is int*?

前端 未结 3 1860
执念已碎
执念已碎 2021-01-11 14:56

simple question, I import a DLL function and the parameter are int*. When I try to enter Method(0), I get an error which says: \"int and int* can not convert\".

What

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 15:39

    It depends on the language you use. In C#, you should declare the argument with the "ref" keyword. In VB.NET you should use the ByRef keyword. And you need to call it by passing a variable, not a constant. Something like this:

     int retval = 0;
     Method(ref retval);
     // Do something with retval
     //...
    

提交回复
热议问题