[英]correct format for Input string
我有如下的帮助方法。
@helper DisplayTrendIndicator(double lastYear, double twoYearsAgo)
{
if (lastYear > twoYearsAgo)
{
<img id="green" src="@VirtualPathUtility.ToAbsolute("~/images/up.png")" />
}
else
{
<img id="red" src="@VirtualPathUtility.ToAbsolute("~/images/down.png")" />
}
}
当我尝试在程序中调用该方法时,出现“输入字符串格式不正确”的提示。 这就是我所说的上述助手
@Helpers.DisplayTrendIndicator(double.parse(lastYear.Content), double.parse(twoYearsAgo.Content))
注意:lastYear和twoYears是从API调用返回的变量。 我正在研究ASP.NET MVC项目C#。 如何防止出现此错误。
从API调用返回的变量lastYear和twoYears的值是什么?
尝试使用Convert.ToDouble()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.