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.
Get Professional C# 6 and .NET Core 1.0 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.