由CultureInfo的格式字符串 [英] Format string by CultureInfo
本文介绍了由CultureInfo的格式字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要显示英镑符号和格式0.00即£45.00,£4.10。我使用下面的语句:
I want to show pound sign and the format 0.00 i.e £45.00, £4.10 . I am using the following statement:
<td style="text-align:center"><%# Convert.ToString(Convert.ToSingle(Eval("tourOurPrice")) / Convert.ToInt32(Eval("noOfTickets")), new System.Globalization.CultureInfo("en-GB")) %></td>
但它不工作。这是什么问题。
But it is not working. What is the problem.
任何一个可以帮助我吗?
Can any one help me???
推荐答案
使用货币
string.Format(new System.Globalization.CultureInfo("en-GB"), "{0:C}", amount)
CultureInfo的可以作为格式提供,也将让你的文化正确的货币符号。
The CultureInfo can act as a format provider and will also get you the correct currency symbol for the culture.
您的例子就是再读取(间隔为便于阅读):
Your example would then read (spaced for readability):
<td style="text-align:center">
<%# string.Format(new System.Globalization.CultureInfo("en-GB"),
"{0:C}",
Convert.ToSingle(Eval("tourOurPrice"))
/ Convert.ToInt32(Eval("noOfTickets")))
%>
</td>
这篇关于由CultureInfo的格式字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文