Valhalla Legends Forums Archive | .NET Platform | Pointer to a Structure? [VB.NET]

AuthorMessageTime
TheMinistered
Is there any other method of retrieving a pointer to a structure other than the Marshall.StructureToPtr function?
April 27, 2004, 11:08 PM
K
Not that I know of in VB.NET.

However, in C#:

[code]
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);
   }
}
[/code]
April 28, 2004, 12:12 AM

Search