我想比较 2 个变量(键入 mvcHtmlString),但响应总是错误的......
@{ //Load the good css file
if (ViewBag.BrowserName == MvcHtmlString.Create("ie"))
{
if (ViewBag.BrowserVersion > 9)
{
@Styles.Render("~/Content/ie10-css")
}
else
{
@Styles.Render("~/Content/ie7-css")
}
}
else if (ViewBag.BrowserName == MvcHtmlString.Create("safari")) //and ipad
{
@Styles.Render("~/Content/safari/css")
}
else //if (ViewBag.BrowserName == "firefox" || ViewBag.BrowserName == "chrome")
{
@Styles.Render("~/Content/default/css")
}
}
我的控制台显示:
MvcHtmlString.Create("safari") -> {safari}
ViewBag.BrowserName -> {safari}
ViewBag.BrowserName == MvcHtmlString("safari") -> false
请问为什么是假的?