I found the following code snippet in the DbSet class for EntityFramework:
public new Type GetType()
{
return base.GetType();
}
I have no idea why the base method is hidden, all base classes have a method implemented by the calling base.
This is object.GetType():
[SecuritySafeCritical]
[__DynamicallyInvokable]
[MethodImpl(MethodImplOptions.InternalCall)]
public extern Type GetType();
This is in class DbQuery:
[EditorBrowsable(EditorBrowsableState.Never)]
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
public new Type GetType()
{
return base.GetType();
}
And this is in class DbSet( DbSet<TEntity> : DbQuery<TEntity>):
[SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")]
[EditorBrowsable(EditorBrowsableState.Never)]
public new Type GetType()
{
return base.GetType();
}
Why or when do you use the keyword newand then invoke the base implementation?
Mafii source
share