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 is that meaning?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That is classic C notation for a
pointer to an int. Whenever a type is followed by a*, it denotes that type as a pointer to that type. In C#, unlike in C, you must explicitly define functions asunsafeto use pointers, in addition to enabling unsafe code in your project properties. A pointer type is also not directly interchangeable with a concrete type, so the reference of a type must be taken first. To get a pointer to another type, such as an int, in C# (or C & C++ for that matter), you must use the dereference operator&(ampersand) in front of the variable you wish to get a pointer to:‘Unsafe’ code C#
Below are some key articles on unsafe code and the use of pointers in C#.