Tag Archives: optional 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 nullable parameters in C#

This example shows how you can use nullable parameters to simulate optional parameters. The example Use null to simulate optional parameters in C# explains how you can pass null to a method to simulate optional parameters, but that only works … Continue reading

Posted in OOP, syntax | Tagged , , , , , , , , , , | Leave a comment

Use null to simulate optional parameters in C#

This example shows how you can use null to simulate optional parameters in older versions of C#. The example Use overloaded methods to simulate optional parameters in C# shows how you can use overloaded methods to simulate optional parameters. Another … Continue reading

Posted in OOP, syntax | Tagged , , , , , , , , , , | 1 Comment

Use overloaded methods to simulate optional parameters in C#

This example shows how you can simulate optional parameters if you’re using an older version of C#. Named and optional parameters were introduced in C# 2010. If you’re using an older version, you should probably upgrade if you can. But … Continue reading

Posted in OOP, syntax | Tagged , , , , , , , , , | 1 Comment