繁体   English   中英

窗口C#中的货币格式

[英]Currency format in window c#

桌面窗口应用程序。

我有一个文本框,用户可以在其中输入数字值。

我想要的是,当用户在文本框中输入金额时,离开该文本框之后,金额应转换为印度货币格式。 例如。如果我输入12345678,则输出将为1,23,45,678.00

谢谢

value.ToString("C"); is enough to convert to currency format. 

有关详细信息,请访问http://msdn.microsoft.com/zh-cn/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("$","")); decimal moneyvalue = 1921.39m; string html = String.Format("Order Total: {0:C}", moneyvalue); Console.WriteLine(html.Replace("$",""));

这只是一个示例,完整的实现取决于您的代码

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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM