又是语法糖。
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;