Demonstrate pass-by-value semantics. - CSharp Custom Type

CSharp examples for Custom Type:Method Parameter

Description

Demonstrate pass-by-value semantics.

Demo Code

using System;//from w ww  .java 2 s . c o  m
public class Program
{
   public static void Update(int i, double d)
   {
      i = 10;
      d = 20.0;
   }
   public static void Main(string[] args)
   {
      int i = 1;
      double d = 2.0;
      Console.WriteLine("Before the call to Update(int, double):");
      Console.WriteLine("i = " + i + ", d = " + d);
      Update(i, d);
      Console.WriteLine("After the call to Update(int, double):");
      Console.WriteLine("i = " + i + ", d = " + d);
   }
}

Result


Related Tutorials