为什么要以更短的方式做到这一点?我想到了类似的东西void DoSth(int i) : DoSth(i, this);.
class Foo
{
void DoSth(int i)
{
DoSth(i, this);
}
static void DoSth(int i, Foo foo)
{
// do sth
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:忘static了第二个功能
如果您使用的是C#6,则可以在类似方法的成员上使用表达式主体:
class Foo
{
public DoSth(int i) => DoSth(i, this);
static void DoSth(int i, Foo foo)
{
// do sth
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
64 次 |
| 最近记录: |