CSharp examples for Custom Type:Method Parameter
A method has a sequence of parameters.
Parameters define the set of arguments that must be provided for that method.
using System;//w ww. j a v a2 s . c o m class Test { static void Foo (int p) { p = p + 1; // Increment p by 1 Console.WriteLine (p); // Write p to screen } static void Main() { Foo (8); // Call Foo with an argument of 8 } }
You can control how parameters are passed with the ref and out modifiers:
Parameter modifier | Passed by | Variable must be definitely assigned |
---|---|---|
(None) | Value | Going in |
ref | Reference | Going in |
out | Reference | Going out |