Code Generation for Overrides in Visual Basic .Net 2005

Code Generation for Overrides in Visual Basic .Net 2005

  • Comments 1


by Mike Carter

Some subtle changes were made in Visual Basic .Net 2005 to make code generation of overidden methods a little easier.  In Visual Basic .Net 2003 and earlier, you used the code dropdowns as in Figure 1 below.

Figure 1

When overriding a Sub, a declaration stub similar to the following was generated in the editor.

Public Overrides Sub MyOverridableSub()

End Sub

In Visual Basic .Net 2005, you never have to leave the code editor.

Figure 2

You can generate a method stub for your overridable methods by just entering "overrides " on a new line in the editor, as in Figure 2. An Intellisense window is displayed with a list of all overridable members in entire iheritance hierarchy for the inherited class.  In this case, BaseClass which inherites from System.Object.  Therefore, overridable members from BaseClass and System.Object are displayed.  When you select a method,  a declaration stub is generated with a call to the base method similar to the following.

Public Overrides Sub MyOverridableSub()
End Sub
This is just one subtle way in Visual Basic .Net 2005 in which we are trying to make your development experience a little easier.
Leave a Comment
  • Please add 3 and 3 and type the answer here:
  • Post
  • I miss the drop down, though I love the enhanced intellisense. The dropdown also let me see what was already overridden and, perhaps most importantly, let me see what was available to be overridden.
Page 1 of 1 (1 items)