July 2019
Intermediate to advanced
410 pages
10h 32m
English
A class is a group or template definition of the methods and variables that describe an object. In other words, a class is a blueprint, containing the definition of the variables and the methods that are common to all instances of the class called objects.
Let's take a look at the following code example:
public class PetAnimal{ private readonly string PetName; private readonly PetColor PetColor; public PetAnimal(string petName, PetColor petColor) { PetName = petName; PetColor = petColor; } public string MyPet() => $"My pet is {PetName} and its color is {PetColor}.";}
In the preceding code, we have a PetAnimal class that has two private fields called PetName and PetColor, and one method called MyPet().
Read now
Unlock full access