O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required