Home » U++ Library support » U++ Core » Value: String to int - problem or feature?
Re: Value: String to int - problem or feature? [message #36394 is a reply to message #36391] |
Wed, 23 May 2012 20:42 |
|
Hi Steffen,
Value is not meant meant for converting types. It is just container that can store various types. In most cases, you always get out the same type you put in. If there implicit conversion is possible, it will be done the same way as you can do e.g. <double> = <int>, but for incompatible types such as int and String, error occurs.
What you need to do is to call StrInt in between:Value v = "122";
int i = StrInt(v); If you are not sure what is in your Value variable, you can test it before the conversion using Is<>() method, e.g:Value v = "122";
if (v.Is<int>()) { ... }
else if (v.Is<String>()) { ... }; Also, as a special case, you can convert any type of Value into String using v.ToString().
Did that answered your question?
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Sat Sep 21 03:25:41 CEST 2024
Total time taken to generate the page: 0.03560 seconds
|