Advertisement
Guest User

Untitled

a guest
Jul 12th, 2014
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. namespace ConsoleApplication1
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. Child2 s = new Child2();
  8. s.foo();
  9. }
  10. }
  11. class Base
  12. {
  13. public virtual void foo()
  14. {
  15. Console.WriteLine("base");
  16. bar();
  17. }
  18. public virtual void bar()
  19. {
  20. //hey I m here just for purpose, I know I m so reduntant
  21. }
  22. }
  23. class Child1 : Base
  24. {
  25. public override void bar()
  26. {
  27. Console.WriteLine("bar in child1");
  28. }
  29. }
  30. class Child2 : Child1
  31. {
  32. public override void foo()
  33. {
  34. Console.WriteLine("child2");
  35. base.foo();
  36. }
  37. }
  38. }
  39.  
  40. child2
  41. base
  42. bar in child1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement