.NET Compilation Error when using TryParse

  

Hi All,

I have a problem in the integrations studio. I have build a extension in .NET but it will not compile when I use this line of code:

bool isNumber = Double.TryParse(number, out Double result);

I am getting an error about the Tools Version who is 12.0 in my project and it is forced to compile with version 4.0 and the following lines of errors:

Class.cs(167,64): error CS1026: ) expected
Class.cs(167,70): error CS1002: ; expected
Class.cs(167,70): error CS1525: Invalid expression term )

The strong typed line of code is on the line 167 of the Class. 

What can I do to fix this problem? 

Thanks


Solution

Hi

Could you try this instead?

bool isNumber = Double.TryParse(number, out result);

If result is not of double type and you want to force it, you can do like this (not sure if it works): 

bool isNumber = Double.TryParse(number, out (double)result);

Cheers,
Eduardo Jauch

Solution

Eduardo Jauch wrote:

Hi

Could you try this instead?

bool isNumber = Double.TryParse(number, out result);

If result is not of double type and you want to force it, you can do like this (not sure if it works): 

bool isNumber = Double.TryParse(number, out (double)result);

Cheers,
Eduardo Jauch

Eduardo, Thank you very much. 

bool isNumber = Double.TryParse(number, out result);

was the solution. after doing this I have made an field "private double result;" and it is fixed.