当我编写代码时,我遇到了像这样的函数=>
public RelayCommand(Action<object> execute): this(execute, null)
Run Code Online (Sandbox Code Playgroud)
我真的不知道这里的"这个"关键词用法
它是构造函数链接. this(execute, null)调用在该类中定义的另一个构造函数,该构造函数接受一个Action<object>和其他值.例如:
class Whatever
{
public Whatever() : this("string arg") {} // calls Whatever(string)
public Whatever(string something) {}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
91 次 |
| 最近记录: |