Welcome :Guest

Congratulations!!!

Top 5 Contributors of the Month
hdjk11
Shivakumaran
dfefde5
hoangnganvy1993

 Home >> Articles >> XML >> Post New Resource

# C# - XML Documentation : Practical scenario

Posted By:Gaurav Arora       Posted Date: April 28, 2009    Points: 25    Category: XML    URL: http://www.dotnetspark.com

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

{
///

/// This class provides basic mathematic methods
/// like addition, substraction, multiplication etc.
/// public class mathclass
{
///
/// The first method is add,
/// which adds the two numbers of int type
/// /// First number to add
/// Result of the addition (int)
public int add(int num1, int num2)
{
return num1 + num2;
}
///
/// The Second method is Susbtract
/// which substract two intergers
///

/// First number to substract
/// Second number to substract
/// Result substraction (int)
public int substract(int num1, int num2)
{
return num1 - num2;
}
///
/// The third method is multiplication
/// which multiply two integers
///

/// First number to multiply
/// Second number to multiply
/// Result Multiplication (int)
public int multiply(int num1, int num2)
{
return num1 * num2;
}
///
/// Fourth method is division
/// which divide two integers
///

/// First number to divide
/// Second number by divide
/// Result division (int)
public int divide(int num1, int num2)
{
return num1 / num2;
}
///
/// Fifth method is Saquare of an integer
///

/// Number for Square
/// Result square (int)
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.

-
-
mathclassXML

-
-

CSharp.AStepAhead.mathclass.mathclass Class This class provides basic mathematic methods like addition, substraction, multiplication etc.

-
The first method is add, which adds the two numbers of int type

-
The Second method is Susbtract which substract two intergers
First number to substract
Second number to substract
Result substraction (int)

-
The third method is multiplication which multiply two integers
First number to multiply
Second number to multiply
Result Multiplication (int)

-
Fourth method is division which divide two integers
First number to divide
Second number by divide
Result division (int)

-
Fifth method is Saquare of an integer
Number for Square
Result square (int)

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 response found. Be the first to respond this post

Post Comment