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?
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.
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.
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
Related
We used to be able to highlight a field and click Ctrl+. And we would get an option to create a constructor with an argument that would then be assigned to the field. See here.
Now in Visual Studio 2019 it's gone.
Is there a setting for that somewhere, or did Microsoft deem it unuseful for some reason?
It seems to have changed a bit in functionality from VS 2017 and later. Set the cursor on the class body (or declaration, i.e. public class MyClass...) and execute the same key strokes and you'll get "Generate Constructor" from the Quick Actions menu. Sometimes though it doesn't work and you have to press search Quick Actions and find it manually.
I have installed VS2017 Enterprise 15.9.11 on a new laptop with latest resharper and when I click Ctrl + . on a class type the Quick Actions and Refactorings menu opens but extract interface is missing.
Any idea why it is not showing?
If all the methods in the class are static, you can't use an Interface, so it won't display that option. Just get rid of all static methods - they're a nuisance and a bad idea anyway.
I want to develop an extension for Visual Studio 2017 which will allow user to right click on C# class and choose to invoke wizard from the context menu. I see here that it is possible with VSIX template. I also looked into Roslyn and feels that it might be the way to go forward but not sure. Basically I wan to select the class and read all it's properties hierarchically to show it in tree view and let user decide select from those. The point I am stuck at is if it is possible in Roslyn and can I use C# reflection there as well.
Thanks
Jay
I use to develop with eclipse and am missing some things on VisualStudio 2013
As you can see in the gif below, I can use a ctrl + t shortcut to see which classess are imlpementing my interface IFoo so I can see the details (in this case Microwave51 class)..How can I do the same trick on VS-2013,
This question here is pretty good but only since 2015
Edit:
If I do Right click on the interface declaration and click "Go To Implementation" I get only this:
If you have ReSharper...
Right click on the interface declaration and click "Go To Implementation."
If you don't...
Right click on the interface and "Find All References." Gotta look through the results manually.
Is there a way in Visual Studio 2010 to add a new file (class) to a project that inherits from an existing base class, abstract or otherwise? This seems like a simple concept but I can't find a way to do it.
I'd like to be able to for example right click a class name in the IDE and and select "add new inheriting class" or something similar. Just one of those things that would save a lot of repetition. Ideally it would implement (generate stubs) for abstract members, etc.
Does anyone know a way to do this either through stock VS2010 or ReSharper? I've dug through both and can't find anything. Interestingly enough, Resharper will allow for generating a superclass, but not a subclass..
I don't think it's actually faster to right click -> add base class then to add a class file and type : Base behind it.
If you want to implement an abstract class you can right click on the base class and select "Implement Abstract Members"
You can also use the Class Diagram tool (right click a project and select View Class Diagram) then add a class and drag an inheritance arrow from the toolbox onto it.
If you are adding Form or User control, this option is available in VS2010, under Windows Forms Tab.
You could create a new item template for the base class(es) you find yourself using most often. Or you could extend Visual Studio and roll your own.