C# Object


object (System.Object) is the base class for all types. Any type can be upcast to object.


The object class has the following members:

public class Object
{/*www  .java  2 s .c o  m*/
  public Object();
  public extern Type GetType();
  public virtual bool Equals (object obj);
  public static bool Equals  (object objA, object objB);
  public static bool ReferenceEquals (object objA, object objB);
  public virtual int GetHashCode();
  public virtual string ToString();
  protected override void Finalize();
  protected extern object MemberwiseClone();

object(System.Object) is the super class for all types. We can always cast to object.

using System;//w  ww.  j a  v  a2  s .c  o m

class Rectangle{

class Program
    static void Main(string[] args)

        object o = new Rectangle();

The code above generates the following result.

Home »
  C# Tutorial »
    Custom Types »

C# Class
C# Struct
C# Interface
C# Inheritance
C# Namespace
C# Object
C# Delegate
C# Lambda
C# Event
C# Enum
C# Attribute
C# Generics
C# Preprocessor