2.13. Function Parameter Semantics

The parameters of a function serve as placeholders within the function body. With each invocation, the parameters are bound to the actual arguments passed to the function. By default, this binding is carried out by value. We can override the default by modifying the parameter with either the ref or the out keyword. These kinds of parameters are bound by reference.

Each parameter minimally consists of a type specifier, such as int, string, or Matrix, and a name. The parameter name is visible only within the function, so the name can be reused outside the function without conflict. A comma separates multiple parameters. We write

f( int i, int j ){ ... }

not

// error!
f( int i, j ){ ... }

An empty parameter ...

Get C# Primer: A Practical Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.