var response = filterContext.Response = filterContext.Response ?? new HttpResponseMessage();两个等于号是什么意思?大佬详细解答下这句语句所有的点,谢啦。
解决方案 »
- 求助:用repeater控件从Access数据库两张表里读取数据,显示到页面上
- NVelocity模板引擎如何传参数?
- 在子页中的对象加载到母版页时会发生改变,比如子页中的对象TextBox1 到母版页中变成了ctl00$ContentPlaceHolder1$TextBox1。
- 问一下接口的兼容性
- 关于combobox的这个问题看你会不会?
- 如何在ASP.NET网站中修改后台管理密码?
- 如何建立一个可供其它事件访问的对象
- 求助~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Default.aspx 与MasterPage.master的区别
- <%=dvbbs.Forum_info(0)%>z这句是什么意思啊 ?
- C# 一个委托执行一个带引用参数的方法,获取返回值?
- AOP(依赖注入)框架,用哪一种框架好一些
filterContext.Response = filterContext.Response ?? new HttpResponseMessage();
var response = filterContext.Response;
if( filterContext.Response==null)
{
filterContext.Response=new HttpResponseMessage();
}var response=filterContext.Response;
a??b代表 a如果是null,就赋值b
int a=0;
int b=0;
int? c=null;
a=b=(c??1);从右到左。 c??1 当 c==null 赋值1,
然后将结果给b,接着b的结果给a。
if(response == null)
{
response = new HttpResponseMessage();
filterContext.Response = new HttpResponseMessage();
}不过个人看法,我是严重反对这种故作高深,从高空摔下来还需要在空间转体360度的方式。代码可读性为第一要素,除非这样写有明显的效率差别。
Sorry,括号中第二句应当是filterContext.Response = response,按址引用关系了。
var response = (filterContext.Response = filterContext.Response ?? new HttpResponseMessage());
这样明白了吧
a=b?c:d;
(如果b为真,那么a=c,如果b为假,那么a=d)a=b??c;
(如果b为null,那么a=c,否则a=b)
其实也就等同于
a = (b==null?c:b)