I am attempting to learn OOP. The book I am using has the examples in C++. I am attempting to modify the code in C#. .Net doesn't like Personisplay(); in the Student class below. Can someone tell me how this should be modified with C#. Thanks.
using System;
namespace LevelInheritance
{
/// <summary>
/// Summary description for Person.
/// </summary>
public class Person
{
protected int m_ID;
protected string m_First;
protected string m_Last;
public Person()
{
m_ID = 0;
m_First = "\0";
m_Last = "\0";
}
public virtual void Display()
{
Console.WriteLine("ID: " + m_ID +
"\rFirst: " + m_First +
"\rLast: " + m_Last);
}
public void Write(int ID, string First, string Last)
{
m_ID = ID;
m_First = First;
m_Last = Last;
}
}
class Student: Person
{
protected int m_Graduation;
public new virtual void Display()
{
Personisplay();
Console.WriteLine("Graduation: " + m_Graduation);
}
public void Write(int ID, string First, string Last, int Graduation)
{
Person:Write(ID, First, Last);
m_Graduation = Graduation;
}
public Student()
{
m_Graduation = 0;
}
}
using System;
namespace LevelInheritance
{
/// <summary>
/// Summary description for Person.
/// </summary>
public class Person
{
protected int m_ID;
protected string m_First;
protected string m_Last;
public Person()
{
m_ID = 0;
m_First = "\0";
m_Last = "\0";
}
public virtual void Display()
{
Console.WriteLine("ID: " + m_ID +
"\rFirst: " + m_First +
"\rLast: " + m_Last);
}
public void Write(int ID, string First, string Last)
{
m_ID = ID;
m_First = First;
m_Last = Last;
}
}
class Student: Person
{
protected int m_Graduation;
public new virtual void Display()
{
Personisplay();
Console.WriteLine("Graduation: " + m_Graduation);
}
public void Write(int ID, string First, string Last, int Graduation)
{
Person:Write(ID, First, Last);
m_Graduation = Graduation;
}
public Student()
{
m_Graduation = 0;
}
}