日期:2014-05-18  浏览次数:20392 次

!= ?什么意思
HttpContext.Current.Request.ApplicationPath != "/" ? HttpContext.Current.Request.ApplicationPath : string.Empty
那个高手能给我帮我解释一下 其中的 != ? 是什么意思呀 速救!!!!!!!!!

------解决方案--------------------
?:是三目运算符号。

这个代码就是

if (HttpContext.Current.Request.ApplicationPath != "/)
xxx = HttpContext.Current.Request.ApplicationPath;
else
xxx = string.Empty;
------解决方案--------------------
HttpContext.Current.Request.ApplicationPath != "/" 为true
返回
HttpContext.Current.Request.ApplicationPath
否则返回
string.Empty
eg:
1+1==2?"正解":"错误"
------解决方案--------------------
这个不是用来获取网站根路径的方法么?
------解决方案--------------------


表达式 ? 表达式成立值 :表达式不成立值