If i understand you well, you need to read about
inheritance[
^],
polimorphism[
^].
Have a look at below example. There are 2 classes: Human and Student, where Student inherits from Human. Both classes have
Name
property and additionaly
Student
class have
Class
property.
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Human h = new Human();
Student s = new Student();
Console.WriteLine(h.Name);
Console.WriteLine(s.Name + " class: " + s.Class);
Console.ReadKey();
}
}
class Human
{
private string sName = "Human";
public virtual string Name
{
get {return sName;}
set {sName = value;}
}
}
class Student : Human
{
private string sName = "Student";
private string sClass = "A";
public override string Name
{
get {return base.Name + "->" + sName;}
set {sName = value;}
}
public string Class
{
get { return sClass; }
set { sName = value; }
}
}
}