.NET Tips and Tricks

Blog archive

Document Your Code with IntelliSense

Over a series of articles about commenting, I discussed why the key issue is to write ROC (Really Obvious Code). If you do, then the only comments you need to provide for your methods should be what parameters the method expects, what your method will do with those parameters, what the method will return, and any side effects of executing the method (e.g., database updates). If you bought into that plan (and some readers did not), then the best place to put that documentation is where Visual Studio will make the best use of it: in IntelliSense, by using XML comments.

To create the structure for your XML comments, click your mouse before your method declaration; then, in Visual Basic, type three apostrophes ('''); in C#, type three forward slashes (///). In either case, Visual Studio will add a framework to hold the comments for your method, for each of the parameters the method accepts, and for your method's return value (if any). All you have to do is type in your content.

Not only will the programmers who work on your code find all the information they need when changing your code, the developers who use your methods will find that IntelliSense delivers your documentation to them when they use your methods.

Posted by Peter Vogel on 01/07/2014


comments powered by Disqus

Featured

  • Creating Reactive Applications in .NET

    In modern applications, data is being retrieved in asynchronous, real-time streams, as traditional pull requests where the clients asks for data from the server are becoming a thing of the past.

  • AI for GitHub Collaboration? Maybe Not So Much

    No doubt GitHub Copilot has been a boon for developers, but AI might not be the best tool for collaboration, according to developers weighing in on a recent social media post from the GitHub team.

  • Visual Studio 2022 Getting VS Code 'Command Palette' Equivalent

    As any Visual Studio Code user knows, the editor's command palette is a powerful tool for getting things done quickly, without having to navigate through menus and dialogs. Now, we learn how an equivalent is coming for Microsoft's flagship Visual Studio IDE, invoked by the same familiar Ctrl+Shift+P keyboard shortcut.

  • .NET 9 Preview 3: 'I've Been Waiting 9 Years for This API!'

    Microsoft's third preview of .NET 9 sees a lot of minor tweaks and fixes with no earth-shaking new functionality, but little things can be important to individual developers.

  • Data Anomaly Detection Using a Neural Autoencoder with C#

    Dr. James McCaffrey of Microsoft Research tackles the process of examining a set of source data to find data items that are different in some way from the majority of the source items.

Subscribe on YouTube