using System; namespace inherit { class baseClass { public virtual string getName() { return "leon"; } public virtual void setName(string name) { } } class SubClass:baseClass { public SubClass(string name) { this.name = name; } private string name; public override string getName() { return name; } public override void setName(string name) { base.setName(name); } } class Program { public static void Main(string[] args) { SubClass sub = new SubClass("leon"); string name = sub.getName(); Console.WriteLine(name); sub.setName("kk"); name = sub.getName(); Console.WriteLine(name); Console.Write("Press any key to continue . . . "); Console.ReadKey(true); } } }