Learn .Net Training from the Best Tutors
Search in
In the .NET framework, the base class for all classes is the System.Object
class. Every class in .NET, whether it's a user-defined class or a system class, directly or indirectly inherits from the System.Object
class. The Object
class provides a set of methods that are available to all objects in the framework.
Some of the common methods provided by the Object
class include:
ToString()
: Returns a string representation of the object.Equals(Object obj)
: Determines whether the current object is equal to another object.GetHashCode()
: Returns a hash code for the object.GetType()
: Gets the Type of the current instance.Here's a simple example to illustrate the inheritance hierarchy:
using System; class MyBaseClass { // This class implicitly inherits from System.Object } class MyDerivedClass : MyBaseClass { // This class also inherits from System.Object } class Program { static void Main() { // Creating instances of classes MyBaseClass baseObj = new MyBaseClass(); MyDerivedClass derivedObj = new MyDerivedClass(); // Using Object class methods Console.WriteLine(baseObj.ToString()); Console.WriteLine(derivedObj.GetHashCode()); Console.WriteLine(derivedObj.GetType()); } }
In the example above, both MyBaseClass
and MyDerivedClass
implicitly inherit from System.Object
. The ToString()
, GetHashCode()
, and GetType()
methods, which are part of the Object
class, are available for use in instances of these classes.
Related Questions
Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com
Ask a QuestionRecommended Articles
Learn Hadoop and Big Data
Hadoop is a framework which has been developed for organizing and analysing big chunks of data for a business. Suppose you have a file larger than your system’s storage capacity and you can’t store it. Hadoop helps in storing bigger files than what could be stored on one particular server. You can therefore store very,...
Make a Career as a BPO Professional
Business Process outsourcing (BPO) services can be considered as a kind of outsourcing which involves subletting of specific functions associated with any business to a third party service provider. BPO is usually administered as a cost-saving procedure for functions which an organization needs but does not rely upon to...
Top 5 Skills Every Software Developer Must have
Software Development has been one of the most popular career trends since years. The reason behind this is the fact that software are being used almost everywhere today. In all of our lives, from the morning’s alarm clock to the coffee maker, car, mobile phone, computer, ATM and in almost everything we use in our daily...
Learn Microsoft Excel
Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...
Looking for .Net Training ?
Learn from the Best Tutors on UrbanPro
Are you a Tutor or Training Institute?
Join UrbanPro Today to find students near youThe best tutors for .Net Training Classes are on UrbanPro
The best Tutors for .Net Training Classes are on UrbanPro