本文介绍了从现有的类生成接口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的课程为:
Class MyClass
{
public MyClass { ... }
public string Name { get { ... } }
public int IdNumber { get { ... } set { ... } }
public void GenerateNme {...}
}
这只是一个示例类.我希望从中生成接口.像,MyClass正在实现IMyClass接口.我希望输出是
It is just a sample class. I wish to generate Interface from it. Like, MyClass is implementing IMyClass interface. I wish the output to be
public Interface IMyClass
{
string Name { get; }
int IdNumber { get; set; }
void GenerateNumber();
}
和
MyClass : IMyClass
{
}
它可以手动完成,但我只是好奇地知道,还有其他简单的方法可以完成吗?如果不清楚,请发表评论.
It can be done manually, but I was just curious to know, is there any other simple method to follow to accomplish this? If not clear, leave a comment.
谢谢.
推荐答案
是的,您可以使用Visual Studio从类中提取接口:
Yes, you can extract an interface from a class using Visual Studio:
在目标类文件中:右键单击> 重构> 提取界面...
Inside the target class file: Right Click > Refactor > Extract Interface...
示例
然后
这篇关于从现有的类生成接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!