Object


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.

Table 20-16: Methods Defined by 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.




C# 2.0(c) The Complete Reference
C# 2.0: The Complete Reference (Complete Reference Series)
ISBN: 0072262095
EAN: 2147483647
Year: 2006
Pages: 300

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net