December 2018
Beginner to intermediate
668 pages
15h 30m
English
In Visual Studio 2017, add a return statement to the method, or in Visual Studio Code, write the whole method, as shown in the following code:
// overridden methods
public override string ToString()
{
return $"{Name} is a {base.ToString()}";
}
Run the console application and view the output. Now, when the ToString method is called, it outputs the person's name, as well as the base classes implementation of ToString, as shown in the following output:
John Jones is a Packt.CS7.Employee
Read now
Unlock full access