What is an Object?

You are currently viewing What is an Object?

Overview

An object is a variable type that can hold any data type, but provides low functionality as it cannot perform data type specific properties, methods, or functions. One advantage to an object is that it can be converted into any data type.

In programming, it’s recommended to use the most specific data type for variables, and therefore would not be the Object data type most of the time. For example, if you know you want a variable to hold a string, then you set the data type as String, instead of an Object. An Object data type would only be useful if you didn’t know what kind of data you were going to put into the variable.

You will probably encounter this variable as it is sometimes the default data type for certain activates like the For Each activity.

Contents

What can you do with Objects?

Below are some great examples of the use of Objects:

  • Obtaining Data with an unknown origin

Commonly Used Methods

The following are some commonly used methods for Objects. Methods are actions that objects (i.e. Objects) can perform. To learn more about methods, click here.

For all examples below, we will be using the following Object variables, objectVar1 & objectVar2, which have been assigned as “Blue” and “Red”, respectively:

Equals(Object) - Determines if 2 Objects are Equal

Example Method Example Return Return Type
objectVar1.Equals(objectVar2)
False
Boolean

Equals(Object,Object) - Determines if 2 Objects are Equal

Example Method Example Return Return Type
Object.Equals(objectVar1,objectVar2)
False
Boolean

ToString - Converts an Object into a String

Example Method Example Return Return Type
objectVar1.ToString
"Blue"
String
objectVar2.ToString
"Red"
String

GetType - Returns the data type

Example Method Example Return Return Type
objectVar1.GetType
System.Object
Type