December 2018
Beginner to intermediate
668 pages
15h 30m
English
The Person type we created earlier is implicitly derived (inherited) from System.Object. Now, we will create a new class that inherits from Person.
Add a new class named Employee.cs to the PacktLibrary project.
Modify its code as shown in the following code:
using System;
namespace Packt.CS7
{
public class Employee : Person
{
}
}
Add statements to the Main method to create an instance of the Employee class:
Employee e1 = new Employee
{
Name = "John Jones",
DateOfBirth = new DateTime(1990, 7, 28)
};
e1.WriteToConsole();
Run the console application and view the output:
John Jones was born on Saturday, 28 July 1990
Note that the Employee class has inherited all the members of Person.
Read now
Unlock full access