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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.