Jump to content

string.format function


jteixeira

Recommended Posts

hi, I would like to put 51,5100 into 51,51 using string.format I'm working with visual web developer in C#

help = String.Format("{0:0.00}",gv2.Rows[0].Cells[0].Text);label3.text=help;

gv2.Rows[0].Cells[0].Text =51,5100 and i can't put help = 51,51

Link to comment
Share on other sites

hi, I would like to put 51,5100 into 51,51 using string.format I'm working with visual web developer in C#
help = String.Format("{0:0.00}",gv2.Rows[0].Cells[0].Text);label3.text=help;

gv2.Rows[0].Cells[0].Text =51,5100 and i can't put help = 51,51

Is 51,5100 a floating point number? (Is it equal to 51 + 51/100?)If so, you can get the format like this:
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");help = String.Format("{0:#.##}", 51.5100);label3.Text = help;

You can format to a specific culture with this handy dandy culture chart.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...