Computer Science Canada

Visual C# Question: Displaying Numbers in a Textbox

Author:  rar [ Mon Jun 28, 2010 10:51 am ]
Post subject:  Visual C# Question: Displaying Numbers in a Textbox

So I'm learning C# using Visual C# and I've been trying to display numbers in a textbox. Every time I do it, however, I have to convert a float to a string somehow and it just becomes a hassle. Isn't there an easier way to do this?

Author:  TerranceN [ Mon Jun 28, 2010 11:08 am ]
Post subject:  Re: Visual C# Question: Displaying Numbers in a Textbox

You HAVE to convert to string. I don't know how you're converting, but I have never found this to be a hassle:
code:
float number = 5.346f;
textBox1.Text = number.ToString();


Hope that helps.

Also does anyone know the name of the C# code tags (if there is any)? What I mean is like how you have to put "turing" for Turing and "cpp" for C++, so what do you have to put for C#?

Author:  rar [ Mon Jun 28, 2010 11:18 am ]
Post subject:  Re: Visual C# Question: Displaying Numbers in a Textbox

TerranceN @ Mon Jun 28, 2010 11:08 am wrote:
You HAVE to convert to string. I don't know how you're converting, but I have never found this to be a hassle:
code:
float number = 5.346f;
textBox1.Text = number.ToString();


Hope that helps.

Also does anyone know the name of the C# code tags (if there is any)? What I mean is like how you have to put "turing" for Turing and "cpp" for C++, so what do you have to put for C#?


I figured out my problem. For the second time now, I made the error of just writing ToString instead of ToString(). Thanks!


: