Domanda

I was translating some managed c++ code to c# and I came across a structure member of type void*. Now, 2 objects of that struct is created, one whose void* member accepts a string and another case accepting address of an int variable.

CK_ATTRIBUTE        findTemplate;
findTemplate->pValue = sUserName;

In another case,

int x = 3;
CK_ATTRIBUTE        findTemplate;
findTemplate->pValue = &x;

How would I translate this void* member in c#? Has it something to do with IntPtr?

È stato utile?

Soluzione

In C++ a void pointer can point to anything. It says to the compiler, "Don't check the type of this." The closest translation in c# is Object.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top