Auto-generate an interface implementation in C#?

懵懂的女人 提交于 2019-11-27 22:04:13

问题


I know this is quite lazy but, is there any way on Visual C# 2010 Express to auto-generate an interface implementation? (I don't mean at runtime but at design time, like a code snippet). Perhaps with a third party utility?


回答1:


I'm not familiar with Express enough to know if they removed this feature, but you should just be able to right-click your public class MyClass : MyInterface statement and choose "Implement Inteface".

If this is removed in Express, you can always use Resharper for this feature.




回答2:


Right click on the interface name, you should see a menu option "Implement Interface" or along those lines.

With the cursor on the interface name, you can also press CTRL + . to get the same context menu and options.




回答3:


In Microsoft Visual Basic 2010 Express, I just put the cursor to the end of the Implements line and press Enter - then the stubs are generated automatically

Public Class Class1
  Implements IMyInterface1

move the cursor to the end of the word IMyInterface1 and press Enter



来源:https://stackoverflow.com/questions/3451810/auto-generate-an-interface-implementation-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!