桌面窗口應用程序。窗口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