Call public method from other classes by using the instance of the class. - CSharp Custom Type

CSharp examples for Custom Type:access level

Description

Call public method from other classes by using the instance of the class.

Demo Code

using System;//from   ww w  .ja v a  2  s. c om
class NumberManipulator {
   public int FindMax(int num1, int num2) {
      /* local variable declaration */
      int result;
      if(num1 > num2)
         result = num1;
      else
         result = num2;
      return result;
   }
}
class Test {
     static void Main(string[] args) {
         int a = 100;
         int b = 200;
         int ret;
         NumberManipulator n = new NumberManipulator();
         //calling the FindMax method
         ret = n.FindMax(a, b);
         Console.WriteLine("Max value is : {0}", ret );
     }
}

Result


Related Tutorials