Exercise 3-13 (HelloDate, XML doc with HTML list)
Chapter_3 Exercise_3-12 | Exercise_3-14 |
Exercise 3-13 TCS, p. 86
Exercise 3-13. Add an HTML list of items to the documentation in Exercise_3-12.
CONTENTS: HelloDate.cs HelloDate.xml
HelloDate.cs
///<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>
///<list type="bullet">
///<listheader>
///<term>List</term>
///<description>List of items</description>
///</listheader>
///<item>
///<term>Item 1</term>
///<description>Desciption of item 1</description>
///</item>
///<item>
///<term>Item 2</term>
///<description>Desciption of item 2</description>
///</item>
///</list>
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
*/
HelloDate.xml
<?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>
<list type="bullet">
<listheader>
<term>List</term>
<description>List of items</description>
</listheader>
<item>
<term>Item 1</term>
<description>Desciption of item 1</description>
</item>
<item>
<term>Item 2</term>
<description>Desciption of item 2</description>
</item>
</list>
</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-12 | BACK_TO_TOP | Exercise_3-14 |
Comments
Post a Comment