Important Methods of System.Object Class in C#

1. Equals():

Syntax:

    Public virtual bool Equals(){}

This method is used to compare the state of object not the reference of object.

2. Finalize()

Syntax:

    Protected virtual void finalize(){}

This methodallows an object toattempt to free resources and perform other clean up operation
Before the object is reclaimed by garbage collector

3. GetHashcode():

Syntax:

    Public virtual int Gethashcode(){}

Hash code is calculated by looking towards the state of the object

4. GetType():

Syntax:

    Public Type gettype(0{]

We can say it is the same as GetClas() in JAVA.

We can Get the type of current object.

5. MemberwiseClone():

Syntax:

    Protected object MemberwiseClone(){]

If you Remember shallow Copy,It creates the Shallow copy of the Current Object.

6. ReferenceEquals():

Syntax:

    Public static bool ReferenceEquals(object obj1,object obj2){}

It determines Whether the References of two Object IIS Same or Not.

7 ToString():

Syntax:

It is the Most Familiar Method.

    Public virtual string ToString(){}

It represent The current Object In String format.

Object Class Always on sist of parameter less onstrutor.

Ebook Download
View all
Learn
View all