The Object class is the base class of all the classes in C#. It has the following methods on C#.
| Sr.No | Method & Description |
|---|---|
| 1 | Equals(Object) Determines whether the specified object is equal to the current object. |
| 2 | Equals(Object,Object, Determines whether the specified object instances are considered equal. |
| 3 | Finalize() Allows an object to try to free resources |
| 4 | GetHashCode() default hash function. |
| 5 | GetType() Type of the current instance. |
| 6 | MemberwiseClone() shallow copy of the current Object. |
| 7 | ReferenceEquals(Object,Object) Determines whether the specified Object instances are the same instance. |
| 8 | ToString() Returns a string that represents the current object. |
Let us see an example how to create an object of a class in C#.
Example
using System;
namespace MyApplication {
class Demo {
protected string name = "Website";
protected void Display(string str) {
Console.WriteLine("Tabs: " + str);
}
}
class Test : Demo {
static void Main(string[] args) {
Test t = new Test();
Console.WriteLine("Details: " + t.name);
t.Display("Product");
t.Display("Services");
t.Display("Tools");
t.Display("Plugins");
}
}
}Output
Details: Website Tabs: Product Tabs: Services Tabs: Tools Tabs: Plugins