- Home /
Question by
crzyone9584-2 · Apr 01, 2011 at 06:50 AM ·
stringintconverttostring
Convert int to string
I may of missed it in the Script reference. As of right now I am using
system.convert.ToString();
Is there a better way to change an int to a string to be displayed in a label? I'm using C#
Comment
Best Answer
Answer by robertmathew · Apr 01, 2011 at 06:59 AM
int myInt = 7;
GUILayout.Label(myInt.ToString()); // Works
GUILayout.Label(""+myInt); // Also works
// GUILayout.Label((string)myInt); // Compile error as you cannot convert an int to an object
Best Answer
Answer by Mike 3 · Apr 01, 2011 at 06:51 AM
You can just use
yourint.ToString();
e.g.
var i = 5;
Debug.Log(i.ToString());
http://msdn.microsoft.com/en-us/library/system.object.tostring.aspx
Your answer
Follow this Question
Related Questions
How do I I convert a hastable to a string? 1 Answer
Why Won't This Work? 1 Answer
Converting a string into int is rounding off 1 Answer
Convert Text to float 3 Answers
parseInt givin' me issues! 2 Answers