简体   繁体   English

在C#中自动生成接口实现?

[英]Auto-generate an interface implementation in C#?

I know this is quite lazy but, is there any way on Visual C# 2010 Express to auto-generate an interface implementation? 我知道这很懒,但有没有什么办法在Visual C#2010 Express上自动生成接口实现? (I don't mean at runtime but at design time, like a code snippet). (我不是说在运行时但是在设计时,就像代码片段一样)。 Perhaps with a third party utility? 也许有第三方实用程序?

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". 我不熟悉Express足以知道他们是否删除了这个功能,但你应该能够右键单击你的public class MyClass : MyInterface语句并选择“Implement public class MyClass : MyInterface ”。

If this is removed in Express, you can always use Resharper for this feature. 如果在Express中将其删除,则可以始终使用Resharper来实现此功能。

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 + . 将光标放在界面名称上,也可以按CTRL + . to get the same context menu and options. 获得相同的上下文菜单和选项。

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 在Microsoft Visual Basic 2010 Express中,我只是将光标放在Implements行的末尾并按Enter键 - 然后自动生成存根

Public Class Class1
  Implements IMyInterface1

move the cursor to the end of the word IMyInterface1 and press Enter 将光标移动到单词IMyInterface1的末尾,然后按Enter键

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 有没有一种快速,轻松和免费的方式来自动生成IComparable <T> C#类的实现? - Is there a quick, easy and free way to auto-generate an IComparable<T> implementation for a C# class? 如何自动将记录器调用生成为C#中的源代码? - How to auto-generate logger calls into source code in C#? 使用Composition在C#中自动生成Wrapper类 - Auto-generate a Wrapper class in C# using Composition 使用 C# 自动生成字母数字唯一 ID - Auto-generate alphanumeric unique Id with C# 从 JSON 自动生成 C# 类,包括属性初始值设定项 - Auto-generate C# classes from JSON, including property initializers 我可以在c#中自动生成我的get / set方法吗? - Can I auto-generate my get/set methods in c#? Code-snippet Visual C#同时在其他地方自动生成方法? - Code-snippet Visual C# simultaneously auto-generate methods elsewhere? 您可以自动生成用于在C#中分配对象属性的代码吗? (视觉工作室) - Can you auto-generate code for assigning properties of an object in C#? (Visual Studio) 无法从提取的json自动生成C#对象 - Can't auto-generate C# object from fetched json 如何在注册模型C#ASP.NET MVC 4中自动生成对象? - How to auto-generate objects in the Register Model C# ASP.NET MVC 4?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM