Skip to Main Content
C# 10.0 All-in-One For Dummies
book

C# 10.0 All-in-One For Dummies

by John Paul Mueller
March 2022
Intermediate to advanced content levelIntermediate to advanced
864 pages
19h 46m
English
For Dummies
Content preview from C# 10.0 All-in-One For Dummies

Chapter 10

Improving Productivity with Named and Optional Parameters

IN THIS CHAPTER

Bullet Distinguishing between named and optional parameters

Bullet Using optional parameters

Bullet Declaring and using output parameters

Bullet Implementing reference return types

Parameters, as you probably remember, are the inputs to methods. They’re the values that appear as part of the method’s signature. When the method returns a value (it doesn’t always do so), the parameters provide the data required to generate the output value. Sometimes, the return values are parameters (out parameters), which confuses things.

In ancient versions of C# and most C-derived languages, parameters can't be optional (oddly enough, you find some examples of this ancient code lurking about online just waiting to make you feel hindered). Instead of making parameters optional, you are required to make a separate overload for every version of the method you expect your users to need. This pattern works well, but there are some problems that are explored in this chapter.

C# 4.0 and above have optional parameters. Optional parameters are parameters ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

C# Cookbook

C# Cookbook

Joe Mayo
Head First C#, 4th Edition

Head First C#, 4th Edition

Andrew Stellman, Jennifer Greene

Publisher Resources

ISBN: 9781119839071Purchase Link