Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 4th, 2012  |  syntax: C#  |  size: 0.87 KB  |  views: 69  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.     public class Mammal
  2.     {
  3.         protected string _Name;
  4.  
  5.         public virtual string Name()
  6.         {
  7.                 return (this._Name + " - of type " + this.GetType());
  8.         }
  9.         virtual public Mammal(string Name)
  10.         {
  11.             this._Name = Name;
  12.         }
  13.     }
  14.     public class Dog : Mammal
  15.     {
  16.         public override Mammal(string Name)
  17.         {
  18.             base._Name = Name;
  19.         }
  20.  
  21.         public override string Name()
  22.         {
  23.             return (base._Name + "Dog");
  24.         }
  25.     }
  26.     class Program
  27.     {
  28.         static void Main(string[] args)
  29.         {
  30.             Mammal AnimalA = new Mammal("SubjectA");
  31.             Console.WriteLine("{0}", AnimalA.Name);
  32.  
  33.             Mammal AnimalB = new Dog("SubjectB");
  34.             Console.WriteLine("{0}", AnimalB.Name);
  35.             Console.ReadLine();
  36.  
  37.         }
  38.     }