I am asking this because it seems like using Object seems to be an easy way out to solve certain problems, like "I don't have a specific type, so use Object", etc.
Also the reason this made me curious is because a colleague of mine told me that if .NET was a true object-oriented platform then it wouldn't have to have a catch all type like Object.
So if .NET didn't have the Object type, what would be the alternative ways to solve the occuring problems to make it function just the same?
Also just to note, this is not to bash .NET, as I use it daily in my work. Just want to know more about it.
EDIT: Another note I remembered is because the type Object exists, its effect ripples throughout the whole .NET. Like IEnumerable exists but also IEnumerable<T>. And in many situations you have to implement both the generic and non-generic version of things, etc.
NET type is a collection of members, which may be fields (i.e., they hold data of some type), methods (i.e., they contain code), or nested type definitions, and all members have some level of protection (e.g., public, private, protected).
Because all classes in . NET are derived from Object, every method defined in the Object class is available in all objects in the system. Derived classes can and do override some of these methods, including: Equals - Supports comparisons between objects.
Object, in C#, is an instance of a class that is created dynamically. Object is also a keyword that is an alias for the predefined type System. Object in the . NET framework. The unified type system of C# allows objects to be defined.
I would say that the problem that is solved by Object
is not "I don't have a specific type, so use Object", but rather "I don't really care what type this is; all I need to know it that it is an Object
"
It is a convenience, not only for use as a 'generic' type but also for reflection, garbage collection etc.
Other languages (C++) can do without, but I would hesitate to say that makes those languages more OOP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With