更新时间:2023-02-03 08:29:07
尝试一下:)
try this :)
Session["priceday1"] = "5464";
// Session["priceday1"] = 5464;
double finalPrice;
if (Double.TryParse(Session["priceday1"].ToString(), out finalPrice))
{
finalPrice = finalPrice / 44;
Label1.Text = finalPrice.ToString();
}
else
{
Label1.Text = "Invalid";
}
这是因为ur将字符串除以44会导致您在字符串中转换会话.
this is Because ur dividing string by 44 as ur converting ur session in string.
Label2.Text = Session["priceday1"].ToString() / 44;
从上面的行中删除.ToString(),然后尝试像
Remove .ToString() from above line and try like
Label2.Text = (Convert.Toint32( Session["priceday1"] )/ 44).ToString();
试试这个
Try this
decimal priceday1 = (decimal) Session["priceday1"] / 44;
Label2.Text = priceday1.ToString("C");