【发布时间】:2014-04-07 10:05:57
【问题描述】:
我在C#. 中有一个interface 定义是否有任何工具可以自动创建(生成)具有默认返回类型的该接口的所有空方法?
例如我已经有:
interface ISampleInterface
{
void SampleMethod();
int func(int);
}
我想要:
// auto interface member implementation:
class ImplementationClass : ISampleInterface
{
void ISampleInterface.SampleMethod()
{
return;
}
// changed return type to int according to interface definintion
int ISampleInterface.func(int a)
{
return a;
}
}
【问题讨论】:
-
考虑使用“Re-sharper”工具。
-
VisualStudio 在没有 Resharper 的情况下也是如此。
-
@PranavSingh 仅限 Visual Studio 的某些版本
-
@verdesrobert 哦,我不知道我用过高级、专业和终极版都有。可能快递没有。
-
@PranavSingh 确切地说:D 一些 Express 版本的功能非常少
标签: c# interface code-generation