Call overloaded Method - CSharp Custom Type

CSharp examples for Custom Type:overload

Description

Call overloaded Method

Demo Code

using System;/*from  w w w.j a  v a  2  s  .co m*/
class MethodMatcher
{
   public void DoIt (int x)
   {
      Console.WriteLine("Executing int: " + x);
   }
   public void DoIt (double x)
   {
      Console.WriteLine("Executing double: " + x);
   }
}
class Tester
{
   public static void Main()
   {
      MethodMatcher myMatcher = new MethodMatcher();
      sbyte sbyteValue = 10;
      int intValue = 1000;
      long longValue = 30000;
      Console.Write("Now calling with an sbyte value --> ");
      myMatcher.DoIt(sbyteValue);
      Console.Write("Now calling with an int value --> ");
      myMatcher.DoIt(intValue);
      Console.Write("Now calling with a long value --> ");
      myMatcher.DoIt(longValue);
   }
}

Result


Related Tutorials