user3265963
user3265963

Reputation: 273

Printing out a HTML document in C#

Just to be clear I'm not asking you to do the project for me (This is my 2nd time I use C# ever), just for a little help getting started. I have no idea how to get started on this project and textbook/google search haven't got me anywhere.

Below is a part of the project description. If someone could explain how this works or help me in the search for relevant information it would be greatly appreciated.

Write a single program called MultiplicationTable, that accepts as input a single integer number in the range 1 - 20, and prints out (using Console.WriteLine or Console.Write) a HTML document which displays the multiplication table for the input number.

Example of a command line:

MultiplicationTable.exe 5 > Result.html

should result in a file called Result.html being created in the same folder as the .exe file (note: the > syntax will take care of creating the file, all you need to do is to print out the results using Console.WriteLine as stated above). This file should be a valid XHTML file, with a single table in the body of the document:

Upvotes: 0

Views: 855

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245389

You don't actually need to worry about printing anything (other than writing some strings to the console output). The > just sends the output of an executable to a file rather than stdout. That means your application just needs to act as though it's trying to write some html as output:

Console.WriteLine("<html>");
Console.WriteLine("<head>");
Console.WriteLine("<title>Some Title</title>");
Console.WriteLine("</head>");
Console.WriteLine("<body>");
// Actual multiplication table
Console.WriteLine("</body>");
Console.WriteLine("</html>");

Keep in mind though that this example is not valid XHTML (you'll need to figure out for yourself what constitutes a valid XHTML file) nor will it generate your markup for the actual multiplication table. It's simply an example of what the problem wants you to do.

Upvotes: 2

Related Questions