I have a float value that I want to put into a label.Text.
The float can be positive or negative, I am not sure the best way to do so. I was looking at String.Format but I am not sure how to use it properly.
I have a float value that I want to put into a label.Text.
The float can be positive or negative, I am not sure the best way to do so. I was looking at String.Format but I am not sure how to use it properly.
Why don't you simply convert the float to string using ToString()
textbox1.Text = myFloat.ToString();
And if you are more interested in format
method simply go through this
if your variable is called value holding float value then you can use it like following.
Label.Text = value>0? String.Format("-{0}", value ):String.Format("{0}", value );
Here is working fiddle for testing and playing with string.Format()
=> link