Tag Archives: parameters

Validate optional parameters in C#

The example Use named and optional parameters in C# explains how to use named and optional parameters to let the calling code omit any combination of parameters. In many applications, you may not want to allow the user to omit … Continue reading

Posted in methods, syntax, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Use named and optional parameters in C#

Optional parameters is one of the few additions in recent versions of Visual Studio that are really useful. I usually try to post examples in an older version of C# because it’s easier for someone to move an older example … Continue reading

Posted in methods, syntax, variables | Tagged , , , , , , , , , , , , , | 1 Comment

Use the params keyword in C#

If you use the params keyword before an array parameter used as the last parameter in a method, then the calling code can pass any number of values for that parameter. The following code defines a ShowValues method that can … Continue reading

Posted in methods | Tagged , , , , , , , , , , , | 4 Comments