Chapter 3Objects and Types
WHAT’S IN THIS CHAPTER?
- The differences between classes and structs
- Class members
- Passing values by value and by reference
- Method overloading
- Constructors and static constructors
- Read-only fields
- Partial classes
- Static classes
- Weak references
- The Object class, from which all other types are derived
WROX.COM CODE DOWNLOADS FOR THIS CHAPTER
The wrox.com code downloads for this chapter are found at www.wrox.com/go/procsharp on the Download Code tab. The code for this chapter is divided into the following major examples:
- MathTest
- MathTestWeakReference
- ParameterTest
CREATING AND USING CLASSES
So far, you’ve been introduced to some of the building blocks of the C# language, including variables, data types, and program flow statements, and you have seen a few very short complete programs containing little more than the Main() method. What you haven’t seen yet is how to put all these elements together to form a longer, complete program. The key to this lies in working with classes — the subject of this chapter. Note that we cover inheritance and features related to inheritance in Chapter 4, “Inheritance.”
CLASSES AND STRUCTS
Classes and structs ...
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.
Read now
Unlock full access