Guest User

Untitled

a guest
Jul 25th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace First_program
  5. {
  6.     class parent
  7.     {
  8.         virtual public void msg(){
  9.             Console.WriteLine("parent");
  10.         }
  11.     }
  12.     class child1:parent
  13.     {
  14.         public new void msg(){
  15.             base.msg();
  16.             Console.WriteLine("child");
  17.         }
  18.     }
  19.     class child2:parent
  20.     {
  21.         public override void msg(){
  22.             base.msg();
  23.             Console.WriteLine("child");
  24.         }
  25.     }
  26.     class Program
  27.     {
  28.         static void Main(string[] args)
  29.         {
  30.             parent pr1 = new child1();
  31.             parent pr2 = new child2();
  32.             //////////this three?/////////
  33.             parent pr    = new parent();//
  34.             parent pr_ch = new child1();//
  35.             child1 ch    = new child1();//
  36.             //////////////////////////////
  37.             pr1.msg();
  38.             pr2.msg();
  39.            
  40.             Console.ReadKey();
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment