Consider the following code:
public abstract class Test1
{
public object Data { get; set; }
}
public abstract class Test2<T> : Test1
{
public T Data { get; set; }
}
This will generate the following warning:
'Test2.Data' hides inherited member 'Test1.Data'. Use the new keyword if hiding was intended.
Why is this only a warning and what effect will adding the "new" keyword have?
According to my testing I cannot find any difference once the "new" keyword is added.
Don't get me wrong, I'm all for being explicit, but I was curious as to the benefit of adding "new".
My only thoughts on what it might be are:
- Improved human readability
- Some saving at run-time when the compiler isn't left to figure the inevitable out the long way around