Exercise 3-14 (Hello, world with XML Documentation)
Chapter_3 Exercise_3-13 | Exercise_3-15 |
Exercise 3-14 TCS, p. 86
Exercise 14. Take the program in Exercise 3-1 and add comment documentation to it. Extract this comment documentation and view it with your Web browser.
CONTENTS: Hello.cs Hello.xml
Hello.cs
///<summary>Main (and only) class of the greeting program</summary>
///<remarks>The first program anyone is supposed to write
///when starting to learn a new programming language</remarks>
public class Hello
{
///<summary>Entry point to the program</summary>
///<remarks>Prints a greeting message, <pre>Hello, world!</pre>
///</remarks>
public static void Main()
{
System.Console.WriteLine("Hello, world!");
}
}
/*
mcs Hello.cs
mono Hello.exe
Hello, world!
mcs -doc:Hello.xml Hello.cs
*/
Hello.xml
<?xml version="1.0"?>
<doc>
<assembly>
<name>Hello</name>
</assembly>
<members>
<member name="T:Hello">
<summary>Main (and only) class of the greeting program</summary>
<remarks>The first program anyone is supposed to write
when starting to learn a new programming language</remarks>
</member>
<member name="M:Hello.Main">
<summary>Entry point to the program</summary>
<remarks>Prints a greeting message, <pre>Hello, world!</pre>
</remarks>
</member>
</members>
</doc>
Chapter_3 Exercise_3-13 | BACK_TO_TOP | Exercise_3-15 |
Comments
Post a Comment