System::Double::TryParse

1
2
3
4
5
6
7
8
Double^ test;
										System::String^ str="12.12";
if (Double::TryParse(str, test))
{
rate=test;
}else{
rate=0.0;
}


Got - Error 2 error C2665: 'System::Double::TryParse' : none of the 3 overloads could convert all the argument types

WHY?
closed account (3hM2Nwbp)
You're passing a handle to a double to that method. I'm 99.8% sure it takes a double, not a handle.

* You might consider posting queries like this in the Windows section, thanks.
Last edited on
Ok,is there any solution?
closed account (3hM2Nwbp)
Bad Code:
1
2
3
4
5
6
7
8
Double^ test;  // < -- Never Initialized, even if it compiled it would crash.
System::String^ str="12.12";
if (Double::TryParse(str, test))
{
rate=test;
}else{
rate=0.0;
}


Potentially Good Code:
1
2
3
4
5
6
7
8
Double test = 0;
System::String^ str="12.12";
if (Double::TryParse(str, test))
{
rate=test;
}else{
rate=0.0;
}


Read the documentation on this, I'm going from memory.
Just delete ^ and it compile now. Luc Lieber Thanks.
Last edited on
Topic archived. No new replies allowed.