Overloading functions with ref keyword - CSharp Custom Type

CSharp examples for Custom Type:overload

Description

Overloading functions with ref keyword

Demo Code

using System;//from w w w .  j av  a  2 s .c om
public class myFunc
{
   public myFunc()
   {
      Console.WriteLine("Signature: myFunc()");
   }
   public myFunc( int x )
   {
      Console.WriteLine("Signature: myFunc( int )");
   }
   public myFunc( float x )
   {
      Console.WriteLine("Signature: myFunc( float )");
   }
   public myFunc( ref int x )
   {
      Console.WriteLine("Signature: myFunc( ref int )");
   }
   public myFunc ( ref float x)
   {
      Console.WriteLine("Signature: myFunc( ref float )");
   }
}
class myApp
{
   public static void Main()
   {
      int i = 99;
      float f = 100.00F;
      myFunc first   = new myFunc();
      myFunc second  = new myFunc( 1 );
      myFunc third   = new myFunc( 2.2F);
      myFunc fourth  = new myFunc( ref i );
      myFunc fifth    = new myFunc( ref f );
      myFunc sixth   = new myFunc( 123L );
      myFunc seventh = new myFunc( (byte) 12 );
   }
}

Result


Related Tutorials