Using Pointer to Class/Strcuture in C#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,i am a newbie in C#. I need to use pointer to a class and strcuture that i have defined in C# so that i call pass their memory address to some function called from Win32 dll (Platform Invoke)?

How can i do that? Thanks very much
 
You usually don't use a pointer. Usually it is a matter of defining the
struct correctly, and the defining the p/invode declaration correctly.

Please tell us what what function and the structure so someone can help you
with this


Regards
Brian W






juvchan said:
Hi all,i am a newbie in C#. I need to use pointer to a class and strcuture
that i have defined in C# so that i call pass their memory address to some
function called from Win32 dll (Platform Invoke)?
 
Hi juvchan,

Pointers can be used inside unsafe block with 'Allow unsafe Code
Blocks' to true. Here is the example:

int Num1=10;
unsafe
{
int * ptr =&Num1;
* ptr =20;
Console.WriteLine(Num1);
}

Regards,

Rohit
 
Back
Top