3 Objects and Types
What’s In This Chapter?
- The differences between classes and structs
- Class members
- Expression-bodied members
- Passing values by value and by reference
- Method overloading
- Constructors and static constructors
- Read-only fields
- Enumerations
- Partial classes
- Static classes
- 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/professionalcsharp6 on the Download Code tab. The code for this chapter is divided into the following major examples:
- MathSample
- MethodSample
- StaticConstructorSample
- StructsSample
- PassingByValueAndByReference
- OutKeywordSample
- EnumSample
- ExtensionMethods
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 Chapter 4, “Inheritance,” covers inheritance and features related to inheritance.
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