美文网首页
Expression body properties and f

Expression body properties and f

作者: Tony_HQ | 来源:发表于2017-03-01 10:37 被阅读0次

C# 有很多语法糖

public string Name => "aaabbb";
public string MyName() => "aaabbb";

是不一样的。
有一个很奇特的特性,Expression body properties 会随着Constructor初始化而初始化。如果在Expression body properties 里调用了Constructor会引起死循环。可用static去解决。

相关文章

网友评论

      本文标题:Expression body properties and f

      本文链接:https://www.haomeiwen.com/subject/dqjqgttx.html