Int32.TryParse not returning reference integer

When using the int32.tryparse(string, int) or integer.tryparse(string, int) method, the integer being returned is always 0.

Example below using the assign activity:
string a = “838”
bool b
int c

b = int32.tryparse(a, c)

Returned Results:
b = true
c = 0

I have tried changing up the variables to be arguments since arguments have an In and Out feature and still having the same results. Is there anything I am missing here? I am new to Workflow Foundation and UiPath but have developing background.

I think c is still 0 because the ByRef isn’t working to store the new integer to the variable.

Usually I use Convert.ToInt32(string) or CInt(string)
and that makes more sense to me.

You can also do IsNumeric(string) to determine if it is a number.


Thanks @ClaytonM for the response. Yes I agree with you but its better coding practice to use TryParse in regards to error handling. The question is why isn’t the ByRef not working? Do you have the same results when trying the TryParse?

same issue regarding Double.TryParse as well. The ByRef does not seem to be working at all.

Yeah, I’m not sure why it doesn’t work in UiPath. Maybe it works if you use Invoke Code.

I found this article at Stack Overflow. Seem to be the same issue in regards to Workflow Foundation. Arguments should seem to resolve this issue though.

1 Like

@ClaytonM, I was able to solve this by using the Invoke Method as mentioned in the Stack Overflow link above. I need to take a deeper dive into Workflow Foundation to understand why ByRef values have reference issues.

1 Like