Type Conversion

What are Type Conversions

Type Conversion, also known as typecasting, refers to the action of changing an object, normally a set of data, from one data type to another. For example, you can use a type conversion to convert an Integer to a String so that you can display it in a message box.

Type Conversion can be accomplished in UiPath by either using Methods or Functions and is applicable to almost any data type used in UiPath. A method, just like a function is a set of instructions that perform a task.

The main difference between the two is that a method is associated with an object (primarily a variable), while a function is not. Both of these techniques are easy to use and are interchangeable. Check out the tutorial here in order to learn more about either of these techniques.

Type Conversion is very useful when developing with UiPath as it allows you to convert any data type into one that will be optimal for processing. 

The most common conversion used in UiPath is the ToString Method, which will be explained in greater detail below. The ToString Method converts a set of data of almost any data type into a String Data Type.

Convert.ToString(12345)

Converting Data Types Using Methods

Methods can be used inside any UiPath activity, just like a variable would be. Methods are written out after the variable as a period (.) followed by the name of the method being used. Conversion methods can be shown by the example below:

Below is a chart that lists all of the conversion methods that can be used in Uipath:

Method Converts From Converts To
Convert.ToBoolean()
Any numeric type, String, Object
Boolean
Convert.ToByte()
Any numeric type, Boolean, String, Object
Byte
Convert.ToChar()
String, Object
Char
Convert.ToDateTime()
String, Object
DateTime
Convert.ToDecimal()
Any numeric type, Boolean, String, Object
Decimal
Convert.ToDouble()
Any numeric type, Boolean, String, Object
Double
Convert.ToInt16()
Any numeric type, Boolean, String, Object
Int16
Convert.ToInt32()
Any numeric type, Boolean, String, Object
Int32
Convert.ToInt64()
Any numeric type, Boolean, String, Object
Int64
Convert.ToSByte()
Any numeric type, Boolean, String, Object
SByte
Convert.ToSingle()
Any numeric type, Boolean, String, Object
Single
Convert.ToString()
Any data type
String
Convert.ToUInt16()
Any numeric type, Boolean, String, Object
UInt16
Convert.ToUInt32()
Any numeric type, Boolean, String, Object
UInt32
Convert.ToUInt64()
Any numeric type, Boolean, String, Object
UInt64

Converting Data Types Using Functions

Functions can also be used inside any UiPath activity, just like a variable would be. Functions are written by the function name followed by a set of two parentheses with the variable name within them Conversion functions can be shown by the example below.

Below is a chart that lists all of the conversion functions that can be used in Uipath:

Function Converts From Converts To
Cbool()
Any numeric type, String, Object
Boolean
CByte()
Any numeric type, Boolean, String, Object
Byte
CChar()
String, Object
Char
CDate()
String, Object
DateTime
CDec()
Any numeric type, Boolean, String, Object
Decimal
CDbl()
Any numeric type, Boolean, String, Object
Double
CInt()
Any numeric type, Boolean, String, Object
Integer (Int32)
CLng()
Any numeric type, Boolean, String, Object
Long
Cobj()
Any data type
Object
CSByte()
Any numeric type, Boolean, String, Object
SByte
CShort()
Any numeric type, Boolean, String, Object
Short
CSng()
Any numeric type, Boolean, String, Object
Single
CStr()
Any data type
String
CUInt()
Any numeric type, Boolean, String, Object
UInteger (UInt32)
CULng()
Any numeric type, Boolean, String, Object
ULong
CUShort()
Any numeric type, Boolean, String, Object
UShort