Tyler Durden
Tyler Durden

Reputation: 1228

Translating void* from c++ to c#

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?

Upvotes: 0

Views: 811

Answers (1)

philologon
philologon

Reputation: 2105

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.

Upvotes: 4

Related Questions