Lecture overview -- Keyboard shortcut: 'u'  Previous page: Output Parameters -- Keyboard shortcut: 'p'  Next page: Parameter Arrays -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Help page about these notes  Alphabetic index  Course home  Page 26 : 29
Object-oriented Programming in C#
Data Access, Properties, and Methods
Use of ref and out parameters in OOP

On this we discuss the usefulness of ref and out parameters in object-oriented programming.

How useful are reference and output parameters in object-oriented programming?

  • Public methods with two or more pieces of output

    • Use a number of out parameters

    • Mutate objects passed by value parameters

    • Aggregate the pieces of output in an object and return it

    • Assign the output to instance variables which subsequently can be accessed by the caller

How to handle the situation where two or more pieces of output is required from a method. Notice that out parameters provides one out of several different solutions.

ref and out parameters are relatively rare in the C# standard libraries

Read more about use of ref and out parameters in OOP in the text book version of this material.