![]() |
String to double
I know i ask this in a lot of different areas but its only because I have no idea how to do it. How do I change a string into a double. I tried the following to change a string into an int but it does not work.
[PHP] string myStr = "123" displayBox.text = Convert.ToInt32(myStr);[/PHP] The error that i get is this :
Cannot implicity convert 'int' to 'string' |
Convert.ToDouble()
The reason you got an error is because displayBox.text is a String, and you are assigning an int to a string. Your conversion worked fine. |
Ok thanks. Can I make the double and then put that double in the TextBox?
|
ok i learned that what i just asked won't work.
|
Quote:
|
yep thats what i did
|
Quote:
:
Cannot implicity convert 'int' to 'string'The thing is that you're probably trying to put that into a textBox. So the ToInt32 worked fine , but you have to use : ToString() on it like so : :
displayBox.text = Convert.ToInt32(myStr).ToString();What exactly are you trying to do ? |
:
string x = "123"; |
crawforddavid2006, don't take this the wrong way man, but you really need to learn how to do a bit of research. This could have been found on Google with about 10 mins of searching. Maybe pick up a C# book if you have a good amount of interest in it.
|
After all those replies i guess that crawforddavid2006 solved the problem, but I am posting another way to do it (one-line way of the snippet submitted by Infinite Recursion):
:
string str = "123"; |
| All times are GMT -5. The time now is 12:57 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC