桌面窗口应用程序。窗口c中的货币格式#
我有用户在数字中给出值的文本框。
我想要什么,当用户在文本框和离开该文本框金额应转换为印度货币格式后输入金额。 例如。如果我输入12345678,然后输出将是1,23,45,678.00
感谢
桌面窗口应用程序。窗口c中的货币格式#
我有用户在数字中给出值的文本框。
我想要什么,当用户在文本框和离开该文本框金额应转换为印度货币格式后输入金额。 例如。如果我输入12345678,然后输出将是1,23,45,678.00
感谢
value.ToString("C"); is enough to convert to currency format.
查看详细资料http://msdn.microsoft.com/en-us/library/3ebe5aks.aspx
value.ToString("N"); // Without $ sign , converts to default numeric format
value.ToString("##,##,##,###.00", CultureInfo.InvariantCulture); //As the default format is en-US you need to convert it to the Indian format.
试试这个 decimal moneyvalue = 1921.39m; string html = String.Format("Order Total: {0:C}", moneyvalue); Console.WriteLine(html.Replace("$",""));
这仅仅是一个例子完整的实现依赖于你的代码
首先导致谷歌在c#中的货币。 – gout 2012-03-27 10:02:32
对不起,我错了输出=“订单总额:$ 12,345,678.00”而不是这个输出应该是1,23,45,678.00。这是印度货币格式。 – 2012-03-27 11:08:07
string theAmmount = "123456789123";
int ammountLength = theAmmount.ToString().Length;
theAmmount = theAmmount.Insert(ammountLength - 2, ".");
double ammountDouble = Convert.ToDouble(theAmmount);
CultureInfo cultureInfo = new CultureInfo("en-IN");
string ammountString = string.Format(cultureInfo, "{0:C}", ammountDouble);
string g = ammountString.Substring(4);
通常最好是陪同您的答案中的代码和一些描述... – 2012-04-02 10:26:33
你有什么代码,使远吗?你有什么问题? – DukeOfMarmalade 2012-03-27 09:58:53
我想你想自定义格式化,比如'#,##,##,###。00' – V4Vendetta 2012-03-27 10:19:34
是@V4Vendetta我想要自定义格式。我使用了上面的格式“#,##,##,### .00“。我写了下面的代码:textBox1.Text = Convert.ToDecimal(12345678).ToString(”#,##,##,###。00“); //和这个输出是“12,345,678.00”,但我想要这样的输出“1,23,45,678.00” – 2012-03-27 11:18:52