代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
lblText.Text = string.Format("{0:C2}", 12.345); //¥12.35
Object d = new Object();
d = "12.345";
lblText.Text = String.Format("{0:C2}", d); //12.345
lblText.Text = String.Format("{0:C2}", d.ToString()); //12.345
Object c = new Object();
c = 12.345;
lblText.Text = String.Format("{0:C2}", c); //¥12.35
lblText.Text = String.Format("{0:C2}", c.ToString()); //12.345
}
}
似乎只有数字类型、或可以拆箱为数字类型的Object,String.Format才起效。