As stated above, is it redundant to inherit from Object in c#?
Do both sets of code below result in equivalent objects being defined?
class TestClassUno : Object
{
// Stuff
}
vs.
class TestClassDos
{
// Stuff
}
I snooped around on MSDN but wasn’t able to find anything perfectly conclusive.
If left unspecified every
classdefinition will implicitly inherit fromSystem.Objecthence the two definitions are equivalent.The only time these two would be different is if someone actually defined another
Objecttype in the same namespace. In this case the local definition ofObjectwould take precedence and change the inheritance objectVery much a corner case but wouldn’t point it out if I hadn’t seen it before
Note that the same is not true if you used
objectinstead ofObject. The C# keywordobjectis a type alias forSystem.Objectand hence it wouldn’t matchExample.Object.Of course if you have a truly evil developer you could still cause confusion with
object