I have a label that i want to show it's Text("1234567")
Like A Number With Thousand Separator//
how can i do this with :
Lable1.Text = string.Format(.....;
Lable1.Text = Convet.ToString(.....;
please explain these two.
I have a label that i want to show it's Text("1234567")
Like A Number With Thousand Separator//
how can i do this with :
Lable1.Text = string.Format(.....;
Lable1.Text = Convet.ToString(.....;
please explain these two.
For IFormatProvider information relating to numbers (for use with Convert.ToString(...,IFormatProvider)
), see the remarks section here. You can follow the links to NumberGroupSeparator and other formatting options which have some example code.
String.Format
also can take an IFormatProvider, but it also understands other formatting directly supplied as a string. See the remarks section of the String Format method -- once again you can follow the links to areas of interest like Standard Numerical Formatting which has an example of internationalized "," numbers.
Happy reading.
Addition in response to comment
IFormatProvider is an interface; NumberFormatInfo is one provider. That is, you can specify the format arguments to a new NumberFormatInfo object and pass that as the IFormatProvider. You can see there is a whole host of members you can twiddle with: NumberFormatInfo members. The advantage of an IFormatProvider is that you can create and define your own conversion formats. You can even invoke the Format
method of an ICustomFormatter directly, if you wish -- with some omissions, this is about what String.Format
does for you. You may also be interested in CultureInfo.CurrentCulture.