public member method : Class Instance « Class « C# / CSharp Tutorial






using System;

class MyClass
{
   public int High, Low;
   
   public int Sum() 
   {
      return High + Low;
   }
}

class MainClass {
   static void Main()
   {
      MyClass T1 = new MyClass();
      MyClass T2 = new MyClass();

      T1.High = 76; 
      T1.Low = 57;
      
      T2.High = 75; 
      T2.Low = 53;

      Console.WriteLine("T1: {0}, {1}, {2}", T1.High, T1.Low, T1.Sum ());
      Console.WriteLine("T2: {0}, {1}, {2}", T2.High, T2.Low, T2.Sum ());
   }
}
T1: 76, 57, 133
T2: 75, 53, 128








7.2.Class Instance
7.2.1.Invoke a method in a class
7.2.2.Instance Class Members
7.2.3.Try to change static value in different instance
7.2.4.public member method
7.2.5.Creating an array of objects.
7.2.6.Call GetType and ToString on object instance