Shadow inherited members

During the inheritance we may shadow the members from the parent class. For example,


class Shape{
  int Width;
}

class Rectangle: Shape{
  int Width;
}

The Width from the Rectangle shadows the Width from Shape.

To mark the hidden fields C# uses new modifier.


class Shape{
  int Width;
}

class Rectangle: Shape{
  new int Width;
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.