Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- A a = new A();
- A b = new B();
- a.Print();
- b.Print();
- Console.WriteLine(a.Prop);
- Console.WriteLine(b.Prop);
- A aa = new A();
- B bb = new B();
- aa.Print();
- bb.Print();
- Console.WriteLine(aa.Prop);
- Console.WriteLine(bb.Prop);
- }
- }
- class A
- {
- public string Prop
- {
- get { return "Property of AAAA"; }
- }
- public void Print()
- {
- Console.WriteLine("AAAA");
- }
- }
- class B : A
- {
- public new string Prop
- {
- get { return "Property of BBBB"; }
- }
- public new void Print()
- {
- Console.WriteLine("BBBB");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment