Exercise 3-12 (HelloDate with XML Documentation)

Chapter_3     Exercise_3-11 Exercise_3-13







Exercise 3-12     TCS, p. 86


Exercise 3-12. Find the code for the second version of HelloDate.cs, which is the simple comment documentation example. Execute csc /doc (or equivalent) on the file and view the results with your XML-aware Web browser.




CONTENTS:     HelloDate.cs     HelloDate.xml




HelloDate.cs     TCS, p. 82-83


///<summary>Shows doc comments</summary>
///<remarks>The documentation comments within C#
///are remarkably useful, both within the Visual
///Studio environment and as the basis for more
///significant printed documentation.</remarks>
public class HelloDate
{
///<summary>Entry point</summary>
///<remarks>Prints greeting to
/// <paramref name="args[0]"/>, gets a
/// <see cref="System.DateTime">DateTime</see>
/// and subsequently prints it.</remarks>
///<param name="args">Command-line should have a
///single name. All other args will be ignored.
///</param>
public static void Main(string[] args)
{
System.Console.Write("Hello, {0}. It's: ", args[0]); // no newline
System.Console.WriteLine(System.DateTime.Now);
// System.Console.WriteLine(System.DateTime.Now.ToString());
}
}
/*
mcs HelloDate.cs
mono HelloDate.exe // exception (run-time error)
mono HelloDate.exe James
Hello, James. It's: 7/21/2023 11:05:05 AM
mono HelloDate.exe John Doe
Hello, John. It's: 7/21/2023 11:05:47 AM

mcs -doc:HelloDate.xml HelloDate.cs

*/




Note:  Compare with the original version of HelloDate.cs.











HelloDate.xml     TCS, p. 83-84


<?xml version="1.0"?>
<doc>
<assembly>
<name>HelloDate</name>
</assembly>
<members>
<member name="T:HelloDate">
<summary>Shows doc comments</summary>
<remarks>The documentation comments within C#
are remarkably useful, both within the Visual
Studio environment and as the basis for more
significant printed documentation.</remarks>
</member>
<member name="M:HelloDate.Main(System.String[])">
<summary>Entry point</summary>
<remarks>Prints greeting to
<paramref name="args[0]" />, gets a
<see cref="T:System.DateTime">DateTime</see>
and subsequently prints it.</remarks>
<param name="args">Command-line should have a
single name. All other args will be ignored.
</param>
</member>
</members>
</doc>









Chapter_3     Exercise_3-11 BACK_TO_TOP Exercise_3-13



Comments

Popular posts from this blog

Contents