We have been gives these classes as an example. In the student class the new keyword that is used on the print method...
is it actually needed because you get the same result if it is taken out?
class Program
{
static void Main(string[] args)
{
Student s = new Student("Dave", 1234);
s.Print();
s.Birthday();
s.Print();
Console.ReadLine();
}
}
class Person
{
protected String name;
protected int age;
public void Birthday()
{
age++;
}
public void Print()
{
Console.WriteLine("Name: {0}", name);
Console.WriteLine("Age: {0}", age);
}
}
class Student : Person
{
int id;
public Student(string n, int ID)
{
age = 0;
name = n;
id = ID;
}
public new void Print() //new keyword here
{
base.Print();
Console.WriteLine("ID: {0}", id);
}
}