• Welcome to Valhalla Legends Archive.
 

Pointer to a Structure? [VB.NET]

Started by TheMinistered, April 27, 2004, 06:08 PM

Previous topic - Next topic

TheMinistered

Is there any other method of retrieving a pointer to a structure other than the Marshall.StructureToPtr function?

K

#1
Not that I know of in VB.NET.

However, in C#:


public struct TestStruct
{
   public int i;
   public double d;
};

public class cTmp
{
   static unsafe void Main(string[] args)
   {
      TestStruct s;

      // this may need to be in a fixed() {} block if you allocate
      // s with new() since the CLR can move items around in memory
      TestStruct* pointer = &s;
         
      int i = (int)pointer;
      Console.WriteLine(i);
   }
}