Simplified Interface Implementation a la VS .NET 2003

Another helpful feature of VS .NET 2003 has to do with the implementation of interface types. As you know, when a class or structure agrees to implement a given interface, it must implement all of the members. Assume you wish to support an interface containing six members. While you could type in the member definitions by hand, you will save yourself time (and hand-cramps) by using the following shortcut. Once you type the name of an interface at the type declaration, VS .NET pops up an invitation to (once again) hit the Tab key:

 public class SomeClass 
  : ISomeInterface   // Message pops up to hit the Tab key…
{…}

Once you do, VS .NET will automatically write stub code for each and every member.


Tip from Andrew Troelsen

Posted by: Duncan Mackenzie, MSDN

This post applies to Visual C# .NET 2003