C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






C# files : XML Documentation


Posted Date: 15 Aug 2008    Resource Type: Articles    Category: General
Author: Gaurav AroraMember Level: Gold    
Rating: Points: 10



It's possible to maintain XML documentation of C# files.

Lets rewrite, mathclass.cs (please refer to previos article), using XML documentation tag.

/* This Example is a part of different 
* examples shown in Book:
* C#2005 Beginners: A Step Ahead
* Written by: Gaurav Arora
* Reach at : gaurav.aroraose@yahoo.co.in*/

// File name : mathclassXML.cs

namespace CSharp.AStepAhead.mathclass
{
/// <summary>
/// CSharp.AStepAhead.mathclass.mathclass Class
/// This class provides basic mathematic methods
/// like addition, substraction, multiplication etc.
/// </summary<
public class mathclass
{
/// <summary>
/// The first method is add,
/// which adds the two numbers of int type
/// </summary<
/// <param name="num1">First number to add</param>
/// <param name="num2">Second number to add</param>
/// <returns>Result of the addition (int)</returns>
public int add(int num1, int num2)
{
return num1 + num2;
}
/// <summary>
/// The Second method is Susbtract
/// which substract two intergers
/// </summary>
/// <param name="num1">First number to substract</param>
/// <param name="num2">Second number to substract</param>
/// <returns>Result substraction (int)</returns>
public int substract(int num1, int num2)
{
return num1 - num2;
}
/// <summary>
/// The third method is multiplication
/// which multiply two integers
/// </summary>
/// <param name="num1">First number to multiply</param>
/// <param name="num2">Second number to multiply</param>
/// <returns>Result Multiplication (int)</returns>
public int multiply(int num1, int num2)
{
return num1 * num2;
}
/// <summary>
/// Fourth method is division
/// which divide two integers
/// </summary>
/// <param name="num1">First number to divide</param>
/// <param name="num2">Second number by divide</param>
/// <returns>Result division (int)</returns>
public int divide(int num1, int num2)
{
return num1 / num2;
}
/// <summary>
/// Fifth method is Saquare of an integer
/// </summary>
/// <param name="num1">Number for Square</param>
/// <returns>Result square (int)</returns>
public int square(int num1)
{
return num1 * num1;
}
}
}


Note: Compile the newly coded file with /doc switch; it generates the xml doc file csc /t:library /doc: MathClassXMlDoc.xml mathclass.cs

The following XML file generated: see XML file.

  <?xml version="1.0" ?> 
- <doc>
- <assembly>
<name>mathclassXML</name>
</assembly>
- <members>
- <member name="T:CSharp.AStepAhead.mathclass.mathclass">
<summary>CSharp.AStepAhead.mathclass.mathclass Class This class provides basic mathematic methods like addition, substraction, multiplication etc.</summary>
</member>
- <member name="M:CSharp.AStepAhead.mathclass.mathclass.add(System.Int32,System.Int32)">
<summary>The first method is add, which adds the two numbers of int type</summary>
<param name="num1">First number to add</param>
<param name="num2">Second number to add</param>
<returns>Result of the addition (int)</returns>
</member>
- <member name="M:CSharp.AStepAhead.mathclass.mathclass.substract(System.Int32,System.Int32)">
<summary>The Second method is Susbtract which substract two intergers</summary>
<param name="num1">First number to substract</param>
<param name="num2">Second number to substract</param>
<returns>Result substraction (int)</returns>
</member>
- <member name="M:CSharp.AStepAhead.mathclass.mathclass.multiply(System.Int32,System.Int32)">
<summary>The third method is multiplication which multiply two integers</summary>
<param name="num1">First number to multiply</param>
<param name="num2">Second number to multiply</param>
<returns>Result Multiplication (int)</returns>
</member>
- <member name="M:CSharp.AStepAhead.mathclass.mathclass.divide(System.Int32,System.Int32)">
<summary>Fourth method is division which divide two integers</summary>
<param name="num1">First number to divide</param>
<param name="num2">Second number by divide</param>
<returns>Result division (int)</returns>
</member>
- <member name="M:CSharp.AStepAhead.mathclass.mathclass.square(System.Int32)">
<summary>Fifth method is Saquare of an integer</summary>
<param name="num1">Number for Square</param>
<returns>Result square (int)</returns>
</member>
</members>
</doc>


With the view of above XML file, you get the idea of importance of the XML documentation. The file tells the entire story of the code. It tells about the each and every method with the short description.

Note: In XML documentation
T : Type, M : Member, F : Field




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Interviews  .  C# Syntax  .  Article  .  .net  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Compiling C# Files
Previous Resource: Adapter Pattern: An introduction
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use