Hello I need help I need to convert a int to a string so it can show in a label
Can not implicity convert int to stringBeen trying for days
Page 1 of 1
2 Replies - 194 Views - Last Post: 24 February 2012 - 05:12 AM
Replies To: Can not implicity convert int to string
#2
Re: Can not implicity convert int to string
Posted 24 February 2012 - 05:08 AM
Every object has a .ToString() method so call that:
int i = 0; string str = i.ToString();
#3
Re: Can not implicity convert int to string
Posted 24 February 2012 - 05:12 AM
You would use the ToString() method for that. - You can usually count on that method existing on all objects.
You can also use the String.Format method to do much the same. Useful if you are putting the number into another string.
int number = 42; string number_str = number.ToString();
You can also use the String.Format method to do much the same. Useful if you are putting the number into another string.
int number = 42;
string number_str = String.Format("The number is: {0}", number);
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|