Let's say we have a class called MyClass.
public class MyClass
We also have an interface like so:
public interface MyInterface{
public string SomeFunction(int foo, string bar, short baz){}
}
We want this class to inherit from MyInterface.
public class MyClass: MyInterface
MyInterface has n properties, and i methods. How can I get Visual Studio to automatically implement all those methods and properties without the developer doing any of the legwork?
For C#, you can right click the 'MyInterface' and choose 'Implement Interface' from the context menu. I believe there is a similar (but slightly different) shortcut for VB.NET.
You can simply use shortcut "CTR+." to do that. Position your cursor on MyInterface of "public class MyClass: MyInterface" line, and press "CTR+.", a context menu will show up with "Implement Interface ...".
To automatically implement all inherited methods from an interface:
C# : Just right click on interface(Prefix with 'I') name and select implement interface option.
VB.NET : Just point your cursor after interface(Prefix with 'I') name and hit enter.
Enjoy!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With