Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Generics
  7. {
  8. class A
  9. {
  10. public virtual void show()
  11. {
  12. Console.WriteLine("Hello: Base Class!");
  13. Console.ReadLine();
  14. }
  15. }
  16.  
  17. class B : A
  18. {
  19. public override void show()
  20. {
  21. Console.WriteLine("Hello: Derived Class!");
  22. Console.ReadLine();
  23. }
  24. }
  25.  
  26. class C : B
  27. {
  28. public new void show()
  29. {
  30. Console.WriteLine("Am Here!");
  31. Console.ReadLine();
  32. }
  33. }
  34.  
  35. class Polymorphism
  36. {
  37. public static void Main()
  38. {
  39. A a1 = new A();
  40. a1.show();
  41. B b1 = new B();
  42. b1.show();
  43. C c1 = new C();
  44. c1.show();
  45. A a2 = new B();
  46. a2.show();
  47. A a3 = new C();
  48. a3.show();
  49. B b3 = new C();
  50. b3.show();
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement