C#
  Home arrow C# arrow Page 2 - C# and XML
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
C#

C# and XML
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 3
    2008-11-20

    Table of Contents:
  • C# and XML
  • XML Documentation
  • Predefined XML Tags
  • User-Defined Tags

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    C# and XML - XML Documentation


    (Page 2 of 4 )

    Documentation comments are composed of embedded XML tags. Documentation comments start with three slashes (///), and apply to a type or type-member definition.

    You can also use/** /for documentation comments (notice the extra star), but this format is less supported by the IDE.

    The compiler can extract the documentation comments and output an XML file. Since the compiler understands the source code, it is able to validate the comments for consistency and expands cross-references into fully qualified type IDs.

    The XML documentation file can be placed in the same directory as the application or library. The Visual Studio .NET IDE will automatically load this XML file, such that the documentation is integrated with IntelliSense. If you’re producing a component library, you can use a tool such as NDoc or Sandcastle to produce HTML help files.

    Here is an example of documentation comments for a type. If you’re using Visual Studio .NET, typing a///before a member automatically gets the IDE to prepopulate the summary and parameter tags. Within the documentation, starting a tag with<causes IntelliSense to give you a list of built-in XML documentation annotations.

      // Filename: DocTest.cs
      using System;

      class Test
      {
       
    /// <summary>
       
    /// The Foo method is called from
       
    ///   <see cref="Main">Main</see>
       
    /// </summary>
       
    /// <mytag>user defined tag info</mytag>
       
    /// <param name="s">Description for s</param>
       
    static void Foo(string s) { Console.WriteLine(s); }

        static void Main() { Foo("42"); }
      }

    When run through the compiler using the/doc:<filename> command-line option, the following XML file is generated:

      <?xml version="1.0"?>
     
    <doc>
       
    <assembly>
         
    <name>DocTest</name>
        </assembly>
        <members>
          <member name="M:Test.Foo(System.String)">
           
    <summary>
           
    The Foo method is called from
             
    <see cref="M:Test.Main">Main</see>
            </summary>
            <mytag>user defined tag info</mytag>
            <param name="s">Description for s</param>
          </member>
        </members>
      </doc>

    Every member with a documentation comment has a<member>tag with anameattribute that uniquely identifies the member. Thecref attribute in the<see>tag has been expanded to correctly refer to another code element. The custom documentation element<mytag>is just carried along with the member payload.

    More C# Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "C# 3.0 in a Nutshell, Third Edition, A...
     

    Buy this book now. This article is excerpted from chapter four of C# 3.0 in a Nutshell, Third Edition, A Desktop Quick Reference, written by Joseph Albahari and Ben Albahari (O'Reilly; ISBN: 0596527578). Check it out today at your favorite bookstore. Buy this book now.

    C# ARTICLES

    - Coding a CRC-Generating Algorithm in C
    - Cyclic Redundancy Check
    - Handling Methods and Functions
    - Destroying Objects in C#
    - Creating Objects in C-Sharp
    - Classes and Objects
    - Programming Languages: Managed versus Native
    - LINQ-to-MySQL with DbLinq in C#
    - Working with Dates and Times in C#
    - Generics, Dictionaries, and More
    - More About Generics
    - Working with C# Collections
    - Generics
    - C# and XML
    - Pointers and Arrays in C#





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek