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 : Ob
There is a time when inheriting from object
makes sense — when you have a partial class
definition, and you want to lock down inheritance and prevent other partial declarations from extending a different class. Attempting to inherit from another type in the partial class will then give you the CS0263 Compiler Error.
This only makes sense in the event that your partial class is not already inheriting from another type.
The partial
keyword is not in your code example, but I thought it might be worth mentioning as I found my way here from Google after seeing a similar setup in an API. Aside from inheriting from object
s that don't point to the official System.Object
as others pointed out, there is no benefit in doing so as all classes inherit from object
implicitly.