Thursday, August 19, 2010

Input Parameters in C#

Input Parameter


It is used to receive values, means it just pass values.

e.g

using System;
class Test
{
public void Increment(int a) // here a is an input parameter it just takes value from the Main method.
{
a = a + 10;
Console.WriteLine("a=" + a);
}
}


class MainClass
{
public static vod Main()
{
int x = 10;
Test obj = new Test();
obj.Increment(x); // passing value into the method.
Console.WriteLine("x=" + x);
}
}

No comments: