U++ framework
Do not panic. Ask here before giving up.

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 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1796
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Out of memory panic
Next Topic: Serialize of derived classes
Goto Forum:
  


Current Time: Sat May 30 06:33:46 GMT+2 2026

Total time taken to generate the page: 0.00485 seconds