有些传统的写法,可以简写,之前没留意到,现在才注意到

IDE0031: Null check can be simplified 

 entity.Unit = entity.Unit == null ? null : entity.Unit.Trim();

可以改成

 entity.Unit = entity.Unit?.Trim();


IDE0029 可以简化 Null 检查。 

c.DeedTaxStatus==null?"未缴清": c.DeedTaxStatus,

可以改成    如果 ?? 运算符的左操作数非空,该运算符将返回左操作数,否则返回右操作数。

c.DeedTaxStatus ?? "未缴清"

IDE0037 member name can be simplified

            var results = new { smsCode = smsCode };

可以改成

            var results = new { smsCode };

 

posted on 2019-06-04 13:06  Gu  阅读(823)  评论(0编辑  收藏  举报