object pointer : Unsafe Code : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Unsafe Code »

 

object pointer








    
 

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);
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Unsafe Code