Parameters and Arguments

suggest change

A method can declare any number of parameters (in this example, i, s and o are the parameters):

static void DoSomething(int i, string s, object o) {
    Console.WriteLine(String.Format("i={0}, s={1}, o={2}", i, s, o));
}

Parameters can be used to pass values into a method, so that the method can work with them. That work can be printing the values, modifying the object referenced by a parameter, or storing the values.

When you call the method, you need to pass an actual value for every parameter. At this point, the values that you actually pass in the method call are called arguments:

DoSomething(x, "hello", new object());

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents