It would be OK if you knew why are you hiding in first place, but as you did not know and asked a question, this is most likely your mistake. This
new
keyword and this warning are designed specially for that.
In this context, the
new
means the following:
"Hey, comrade compiler, don't be so smart. I know myself that hiding PropertyChanged
looks stupid. I do this dirty trick on purpose. Actually, I don't need this member. I just like the name of this member and want to use it for something semantically similar, but unrelated event, that's why I use the same name, as a rare exclusion from normal coding practices. Yes, I understand that in case I need to use inherited PropertyChanged
, I will be able to use it through the qualified name base.PropertyChanged
. So, please shut up your stupid warning; I know what I am doing."
Don't mist up this
new
and a constructor call.
As you are asking this question, this is not the case, most likely. Create a different event with some other name. The only case where you use the same name is when you
override a virtual method or implement an interface method. This is a heart of OOP which you are supposed to know very well. Hiding has nothing in common with that. If you are not explicitly specify "override" but use the same name, you simply hide the inherited member behind a completely different member and get the warning for that; you can suppress this warning with
new
. But you cannot override an event, so all you do is hiding. I don't see a reason for doing it in your case.
[EDIT]
I basically understand your purpose. You just need to implement the interface
INotifyPropertyChanged
. Hiding would make your new "implementation" of the class totally fake. You need to just implement it in different classes. If one common base is not an option, you can use several common base classes with virtual implementation method. Another usual approach is a composed member of some "implementor class". (I don't know if this is a design pattern with a well-known name, but this is a typical and well-known
design pattern.)
—SA