BradleyUffner

Shadowed property test

Jun 4th, 2018
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.29 KB | None | 0 0
  1. void Main()
  2. {
  3.     Sub s = new Sub();
  4.     Base b = s;
  5.    
  6.     s.MyProperty = 1;
  7.     b.MyProperty = 2;
  8.    
  9.     Console.WriteLine(s.MyProperty);
  10. }
  11.  
  12. public class Base
  13. {
  14.     public int MyProperty { get; set; }
  15. }
  16.  
  17. public class Sub : Base
  18. {
  19.     private new int MyProperty { get; set; }
  20. }
Add Comment
Please, Sign In to add comment