Coding theory question


So in the code Double.TryParse(CashIn, dbl_CashIn) why do we need the dbl_CashIn? if we are converting the string to double wouldn’t it be TryParse(CashIn)? When I try this I get an error. I’m just trying to understand why I need both. Haha the theory stuff is what Im really trying to understand.

  • The Coding Trucker
1 Like

It’s how this function works. If the parse succeeds, the value will be converted to double and output to the dbl_CashIn variable.
If memory serves me right, I think you will be using this variable some place.

Hello @Asanka @AndyMenon

As @AndyMenon mentioned, try parse will actually try to convert the value to double. We usually use this to overcome runtime errors when converting data from string to other types. Try parse will actually try to convert the value to the given variable, but as I know, it doesnt initialize the variable. I tried this couple of times and printed the value right after the try parse. Though the try parse was successful it returned zero.

We usually do the try parse in an if activity, then if true, we directly assign it using double.Parse