I have an issue on new modifier keyword which is explained below in detail.
public abstract class RangeBase
{
public event RoutedPropertyChangedEventHandler<int> ValueChanged;
public int Minimum { get; set; }
public void OnValueChanged(int oldValue, int newValue)
{
ValueChanged(this, new RoutedPropertyChangedEventArgs<int>(1, 2));
}
}
RangeBase is an abstract class defined a RoutedPropertyChangedEventHandler of type int, a property Minimum of type int and a method OnValueChanged which accepts two int parameters.
public class MyRange : RangeBase
{
public new event RoutedPropertyChangedEventHandler<double> ValueChanged;
public new double Minimum { get; set; }
public new void OnValueChanged(double oldValue, double newValue)
{
ValueChanged(this, new RoutedPropertyChangedEventArgs<double>(1, 2));
}
}
MyRange class derived from RangeBase is also defined a set of fresh members and methods which has same name of Base class members but the type here is double and marked with new modifier keyword. Forget about Generics here.... Now let me explain the real issue.
Members and Properties marked with the new keyword hides the BaseClass Members and Properties of the same name. Here also this works well with me except OnValueChanged method. Intellisense still exposing both Derived and Base class OnValueChanged methods of type int and double. Here I Can hide Minimum property of type int in the BaseClass with the Minimum property of type double in Dervied Class. But it is not working for OnValueChanged method. Could anyone can explain why new keyword is not working in this situation. Thanks in Advance !!!