您的位置:首页 > 其它

Vs 2015 中一些新的语法支持

2015-07-21 17:22 381 查看
又是语法糖。

1,

if (tdata != null && tdata.Data != null)
等价于
  if (tdata?.Data != null)

 

2,

int a = 1 ;

var y = string.Format(“xyz{0}”,a);

相当于

var y = $"xyz{a}";

 

3,

private _cacheToUser = null;

public string CacheToUse
       {
           get { return _cacheToUse; }
           set { _cacheToUse = value; }
       }

相当于

public string CacheToUse { get; set; } = null;

 

4,

private string _s;
      public string S
      {
          get { return _s; }
      }

相当于

private string _s;
public string S => _s;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: