Chapter 4: Let Me Say This about this

In This Chapter

check.png Figuring out how to pass an object to a method

check.png Comparing class methods to instance methods

check.png Understanding what this is

check.png Knowing what to do when you don’t have this

check.png Taking action when a class doesn’t have a method that you need it to have

This chapter moves from the static methods that Chapter 3 in this minibook emphasizes to the nonstatic methods of a class. Static methods belong to the whole class, and nonstatic methods belong to each instance created from the class. Important differences exist between static and nonstatic class members.

Passing an Object to a Method

You pass object references as arguments to methods in the same way as you pass value-type variables, with one difference: You always pass objects by reference.

The following small program demonstrates how you pass objects — to methods, that is:

ontheweb_modern.eps

// PassObject -- Demonstrate ...

Get C# 5.0 All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.