O'Reilly logo

Professional C# 6 and .NET Core 1.0 by Christian Nagel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required