Chapter 3

Let Me Say This about this

IN THIS CHAPTER

Bullet Passing an object to a method

Bullet Comparing class and instance methods

Bullet Understanding this

Bullet Working with local functions

This chapter moves from the static methods emphasized in Chapter 2 in this minibook to the instance methods of a class. Static methods belong to the whole class, and instance methods belong to each instance created from the class. Important differences exist between static and instance class members, such as the passing of objects (no, it's not a matter of objectifying anything — it’s just the term used for all sorts of real-world entities, none of which are degraded by the code in this chapter).

You also discover that the keyword this identifies the instance, rather than the class as a whole, or properties defined as part of the method or passed to the method. The this keyword lets you do all sorts of amazing things.

Chapter 2 also discusses local functions as part of the refactoring process used to make your code more readable. However, you don't have to wait until you refactor your code to use a local function. ...

Get C# 10.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.