jteixeira Posted April 30, 2007 Share Posted April 30, 2007 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 More sharing options...
pulpfiction Posted April 30, 2007 Share Posted April 30, 2007 Try this... string str = @"51,5100";char[] charsToTrim = {'0'};str = str.TrimEnd(charsToTrim);Response.Write(str); Link to comment Share on other sites More sharing options...
Yahweh Posted April 30, 2007 Share Posted April 30, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.