Ask the Expert

Is there some automated way to get skeletons for the methods?

I hate typing signatures for methods I'm overloading or interfaces I'm implementing. With all the cool metadata that .NET has about my types, isn't there some automated way to get skeletons for the methods?
If you've got a base class with virtual or abstract methods or you're implementing an interface, you need to make sure you get the signature right or the compiler is going to be unhappy (have you ever noticed how much time we spend pleasing the compiler?). With the overwhelming support that .NET has for metadata, it seems like a tool could help by filling in skeletons for you for these things. And at least one tool, VS.NET, can. For example, if you derive a class called MyNamespace.MyForm from the Form class and you're like to override the OnClosing method, you can use the Class View (Ctrl+Shift+C) to navigate into ProjectName -> MyNamespace -> MyForm -> Bases and Interfaces -> Form, right-click on the OnClosing method and choose Add -> Override, which will give you a function skeleton like this:
protected override void OnClosing(CancelEventArgs e) {
    // TODO:  Add MyForm.OnClosing implementation
    base.OnClosing (e);
}

Likewise, if you have a custom class MyNamespace.MyClass that implements the IDisposable interface, you can use the Class View to navigate into ProjectName -> MyNamespace -> MyClass -> Bases and Interfaces, right-click on the IDisposable interface and choose Add -> Implement Interface, and you'll get a function skeleton for each method, like so:

class MyClass : IDisposable {
    #region IDisposable Members
    public void Dispose() {
        // TODO:  Add MyClass.Dispose implementation
    }
    #endregion
}

This was first published in October 2002

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: