Passing value to a method - CSharp Custom Type

CSharp examples for Custom Type:Method Parameter

Description

Passing value to a method

Demo Code

using System;/*from   ww  w.ja v a2s . com*/
class nbr
{
   public double square( double x )
   {
      x = x * x;
      return x;
   }
}
class TestApp
{
   public static void Main()
   {
      nbr doit = new nbr();
      double nbr1 = 3;
      double retVal = 0;
      Console.WriteLine("Before square -> nbr1 = {0}, retVal = {1}", nbr1, retVal);
      retVal = doit.square( nbr1 );
      Console.WriteLine("After square -> nbr1 = {0}, retVal = {1}", nbr1, retVal);
   }
}

Result


Related Tutorials