Q

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 last published in October 2002

Dig Deeper on .NET tutorials, guides and quizzes

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.

-ADS BY GOOGLE

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close