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 first 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.

0 comments

Oldest 

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:

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close