cast from sting to int in Visual C++
Hi
I am wrking in Visual C++ (Visual Studio.NET 2003), and i am struggeling to case a String that I read from a text box to an integer (int). Can somone please help me with this. Thanx D:( |
Afaik the string has a method strtol (or something similar). Else there's the C-function strtol or strtoul.
|
.Net has the following method
Code:
public: static short ToInt16(String* value); These are all documented on the MSDN siteConvert Class . However if you want your code to be portable to another framework then you may want to look at the strtol() function, as previously mentioned, as this is part of the standard C library so #include <cstdlib>. graeme. |
A gentle request to please keep your questions in the forum
Quote:
Code:
int var1 = Convert::toInt32(txtTextBox->get_Text()); The IFormatProvider is an optional parameter (if you use the static version of toInt32). I hope that helps, an example of the code to set up an IFormatProvider is given at page to the C++ example graeme |
All times are GMT -5. The time now is 10:58 PM. |