Try Parse output

Hello, What does Try parse exactly do?
what will the ouptut type of try parse
Can someone help me with it.

Hi @Kira

“TryParse” is a method used to attempt parsing a string into a specific data type (e.g., integer, double, date) while avoiding exceptions in case the parsing fails. This method is especially useful when dealing with user input or external data that may not be in the expected format.

The “TryParse” method returns a Boolean value that indicates whether the parsing was successful or not. If the parsing is successful, the method also outputs the parsed value in the specified data type. If the parsing fails, the output variable will be set to the default value for the data type (e.g., 0 for integers, 0.0 for doubles, and DateTime.MinValue for dates).

Here is the basic syntax for the “TryParse” method in UiPath for parsing an integer:

Int32.TryParse(inputString, outputInteger)

Hi @Kira

TryParse method works in a similar way. It is used to convert strings to other data types like Integer, Double, Boolean, etc., but the result is stored in UiPath variables (as UiPath has its own variable types). The TryParse method in UiPath will have a Boolean output to indicate the success or failure of the conversion, and it will store the converted value in the specified variable.

Example: Using Int32.TryParse:

success= Int32.TryParse("123", intValue)

It will return Boolean value.

Hope it helps!!


Tryparse will try to parse or try to convert the given string in the format you want…like date,integer etc…and if successful would return true else would return false


Hey @Kira ,
The TryParse activity when used in assign activity will give you the Boolean output
but when used in Invoke Method Activity it will give you the Required Format output

For eg: if u have a strvar = “19”
then if you try parse in assign activity as integer.TryParse(strvar,0)
So this will return a Boolean output

But if you use it in Invoke method activity

Set the targetType as integer and in the parameters map the input string and output variable
So this will convert it into Integer and provide your Integer output

HI @Kira

It will give you the Boolean as result

It will simply check whether the string can parsed/Convertable or not


What if i want to convert it into differnt type?


Unfortuntelly, in UiPath, Assign activity doesn’t support ref/out argument.
So we can write it as the following, but result won’t be set.

isSuccess = Int32.TryParse("123", intVar)

If you want to get not only boolean but also parsed value, can you try to use InvokeMethd as the following?

Sequence.xaml (5.4 KB)


1 Like

Hey @Kira
Refer below file for reference (3.2 KB)

Hope it helps you out!

1 Like

@Vikas_M and @Yoichi
Thank you so much for the files, it was a great help to understand it using the files you provided

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.