Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace First_program
- {
- class parent
- {
- virtual public void msg(){
- Console.WriteLine("parent");
- }
- }
- class child1:parent
- {
- public new void msg(){
- base.msg();
- Console.WriteLine("child");
- }
- }
- class child2:parent
- {
- public override void msg(){
- base.msg();
- Console.WriteLine("child");
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- parent pr1 = new child1();
- parent pr2 = new child2();
- //////////this three?/////////
- parent pr = new parent();//
- parent pr_ch = new child1();//
- child1 ch = new child1();//
- //////////////////////////////
- pr1.msg();
- pr2.msg();
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment