Classes
Classes are an integral part of coding in C# and will be covered comprehensively in Chapter 2, Building Quality Object-Oriented Code. This section touches upon the basics of classes so that you can begin using them in your programs.
The reserved class
keyword within C# is used when you want to define the type of an object. An object, which can also be called an instance, is nothing more than a block of memory that has been allocated to store information. Given this definition, what a class does is act as a blueprint for an object by having some properties to describe this object and specifying the actions that this object can perform through methods.
For example, consider that you have a class named Person
, with two properties, Name
and Age
, and a method that checks whether Person
is a child. Methods are where logic can be placed to perform some action. They can return a value of a certain type or have the special void
keyword, which indicates that they do not return...