CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Parameter Comments

    Hello all.
    I am using VS2008 (so its .NET 3.5).
    When using a class, eg DateTime() and i have typed the following:

    Code:
    DateTime dt = new DateTime(
    a pop-up is displayed containing the various constructors. It also contains a comment explaining what the various parameters of the constructor does.
    For example, in the attached image you can see the comment saying:
    ticks: A date and time expressed in 100-nanosecond units.
    How do i add such comments to classes/function i create myself??
    Attached Images Attached Images  

  2. #2
    Join Date
    Jul 2006
    Posts
    297

    Re: Parameter Comments

    Its pretty simple...

    Code:
            /// <summary>
            /// Create's a new LoginCookie for a user
            /// </summary>
            /// <param name="userId">UserId of the user who's logging in</param>
            /// <param name="username">Username of the user who's logging in</param>
            /// <param name="domain">Domain of the site who is issuing the cookie</param>
            public LoginCookie(Int32 userId, String username, String domain)
            {
    
            }
    This article might shine some more light on the subject.
    http://msdn.microsoft.com/en-us/library/b2s063f7.aspx

  3. #3
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Parameter Comments

    Just to add one bit of info; just type three '/' characters in a row above a member or method and the skeleton will be generated automatically for you.

  4. #4
    Join Date
    Jul 2009
    Posts
    2

    Re: Parameter Comments

    Thank you guys!
    So this is called "XML Documentation Comments".

    Thanks again!

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Parameter Comments

    The intellisense comments are just the tip of the iceberg.

    Not only do the xml comments allow for these, they also allow you to build complete documentation for your assemblies.

    Check out SandCastle and the SandCastle Help File Builder tools.

  6. #6
    Join Date
    Jul 2006
    Posts
    297

    Re: Parameter Comments

    Never knew the xml comments were so powerful. I always assumed there was a tool to convert them to documentation but never looked for it.

    Now if only I can get my lazy superiors to use xml comments religiously like I do then I might have some decent documentation for the new developers at work.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured