using System;
public struct MyValue
{
public int id;
private decimal price;
public MyValue(int id, decimal price)
{
this.id = id;
this.price = price;
}
public void Foo() { Console.WriteLine("Foo"); }
}
class DerefMemberApp
{
static void Main(string[] args)
{
MyValue i = new MyValue(123, 45.67m);
unsafe
{
MyValue* pi = &i;
(*pi).Foo();
pi->Foo();
Console.WriteLine("id = {0}", pi->id);
}
}
}
|