又是语法糖。

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;

相关文章:

  • 2021-06-22
  • 2022-12-23
  • 2021-05-28
  • 2021-09-08
  • 2022-12-23
  • 2022-12-23
  • 2021-06-07
  • 2021-08-15
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2021-06-25
相关资源
相似解决方案