Declaring Parameters

A method can accept zero or more parameters, which mainly act as inputs to a method, in particular to communicate additional state to it. When no parameters are required, an empty pair of parentheses is still required:

static void PrintUsage(){    Console.WriteLine("Usage:  echo <name>");}

If one or more parameters are required, the parameter list is a comma-separated list of distinctly named parameters, prefixed with a type and optional modifiers.

Note: Parameter or Argument?

Terms that are often confused and incorrectly used interchangeably are parameter and argument. The distinction is quite simple, though. Parameters live on a declaration site (for example, in the parameter list of a method), ...

Get C# 5.0 Unleashed now with O’Reilly online learning.

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