1. Computing

The Object Object

Everything inherits from this .NET Framework object!

From , former About.com Guide

The Object object methods

Everything has a beginning. In the case of .NET, it's the Object object. It's the ultimate superclass of all classes in the .NET Framework. That means that all other .NET classes inherit from this one class. As a result, you can normally use any method that is in Object anytime. Here's the list of methods to be found in Object:

  • Equals
    Compares objects

  • GetHashCode
    Generates hash number value of the object

  • GetType
    Returns the runtime type of the object

  • ReferenceEquals
    Determines whether object instances are the same

  • ToString
    Generates a text string that describes the object

But these methods are frequently overridden to create unique functionality in subordinate objects. For example, if you use the ToString method with a DateTime object ...

 Dim obj As DateTime = Today
 Console.WriteLine(obj.ToString) 

There's a natural string that is available - the date:

 12/7/1941 7:53:00 AM 

But if you pick something that doesn't have such an obvious string interpretation, you'll likely just get some information about the object:

 Dim obj As New TreeView
 obj.Nodes.Add("myNode")
 Console.WriteLine(obj.ToString) 

Output:

 System.Windows.Forms.TreeView, Nodes.Count: 1, Nodes[0]: TreeNode: myNode 

Two methods of the Object object are Protected. The Finalize method performs cleanup operations before the resources of an object are reclaimed. The MemberwiseClone method creates a "shallow copy" of the object.

In another Quick Tip - The ToString Object - I describe how to display the bits in other objects using the ToString method.

  1. About.com
  2. Computing
  3. Visual Basic
  4. Quick Tips
  5. The Visual Basic Object object in the .NET Framework

©2013 About.com. All rights reserved.