Object is the class that underlies the C# object type. The members of Object were discussed in Chapter 11, but because of its central role in C#, its methods are repeated in Table 20-16 for your convenience. Object defines one constructor, which is shown here:
Object( )
It constructs an empty object.
Method | Purpose |
---|---|
public virtual bool Equals(object ob) | Returns true if the invoking object is the same as the one referred to by object. Returns false otherwise. |
public static bool Equals(object ob1, object ob2) | Returns true if ob1 is the same as ob2. Returns false otherwise. |
protected Finalize( ) | Performs shutdown actions prior to garbage collection. In C#, Finalize( ) is accessed through a destructor. |
public virtual int GetHashCode( ) | Returns the hash code associated with the invoking object. |
public Type GetType( ) | Obtains the type of an object at runtime. |
protected object MemberwiseClone( ) | Makes a “shallow copy” of the object. This is one in which the members are copied, but objects referred to by members are not. |
public static bool ReferenceEquals(object ob1, object ob2) | Returns true if ob1 and ob2 refer to the same object. Returns false otherwise. |
public virtual string ToString( ) | Returns a string that describes the object. |