| Author: Selva 28 Sep 2008 | Member Level: Silver | Rating:    Points: 6 |
Hi Do u mean out parameter ? Out paramater is used for passed by reference. It is similar to ref keyword except ref requires the variable to be initialized before use.
Example public static void Sum(int a, int b, out int c) { c = a + b; }
int a; Sum(10, 20, out a); but params lets you to specify a method that taking invariable number of input parameters
Example
public static int Sum(params int [] Input) { int Total=0; for (int i = 0; i < Input.Length; i++) Total += Input[i]; return Total; }
int Total = Sum(100, 200, 200, 300);
|
| Author: Vivek 29 Sep 2008 | Member Level: Gold | Rating:    Points: 6 |
Hi, Output parameters are like reference parameters, except that they transfer data out of the method rather than into it. They are similar to reference parameters. Like a reference parameter, an output parameter is a reference to a storage location supplied by the caller. However, the variable that is supplied for the out parameter does not need to be assigned a value before the call is made, and the method will assume that the parameter has not been initialized on entry. Output parameters are useful when you want to be able to return values from a method by means of a parameter without assigning an initial value to the parameter.
Params (Parameter Array)-
A method that can accept a varying number of parameters. In C#, you can use the params keyword to specify a variablelength parameter list.
static long AddList(params long[ ] v) { long total; long i; for (i = 0, total = 0; i < v. Length; i++) total += v[i]; return total; }
long x = addlist(12, 14, 16);
|