2 Replies - 312 Views - Last Post: 24 February 2012 - 05:12 AM Rate Topic: -----

#1 EvanClark  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 29
  • Joined: 05-January 12

Can not implicity convert int to string

Posted 24 February 2012 - 05:01 AM

Hello I need help I need to convert a int to a string so it can show in a label
Is This A Good Question/Topic? 0
  • +

Replies To: Can not implicity convert int to string

#2 janne_panne  Icon User is offline

  • WinRT Dev
  • member icon

Reputation: 429
  • View blog
  • Posts: 1,047
  • Joined: 09-June 09

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();


Was This Post Helpful? 0
  • +
  • -

#3 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3719
  • View blog
  • Posts: 5,991
  • Joined: 08-June 10

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.
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);


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1