Pass value by reference - CSharp Custom Type

CSharp examples for Custom Type:Method Parameter

Description

Pass value by reference

Demo Code

using System;//from   w w w .j  a  va  2s  .  co m
using System.Text;
class Program
{
   static void Main(string[] args)
   {
      double myDouble = 4.56;
      Console.WriteLine("myDouble in Main: {0}", myDouble);
      incrementDouble(ref myDouble);
      Console.WriteLine("myDouble in Main: {0}", myDouble);
      Console.ReadKey();
   }
   static void incrementDouble(ref double d)
   {
      d++;
      Console.WriteLine("myDouble in incrementDouble: {0}", d);
   }
   static void addExclamationMarks(StringBuilder b)
   {
      b.Append("!!!!!!!");
   }
}

Result


Related Tutorials