output code into formatted web page
문제
hey guys. i was wandering if anyone knew how to create code so that the console is not opened, rather a formatted web page.
any suggestions will be much appreciated!
regards
namespace Grades
{
class Program
{
static void Main()
{
Console.WriteLine("\t\tValue Distribution\n");
String text = File.ReadAllText(@"values.dat"); //obviously change file path again
char[] c = text.ToCharArray(); //convert to char array
var g = c.OrderBy(a => a); //order array
foreach (char group in g)
{
Console.WriteLine(group.ToString()); //loop, displaying ordered array
}
//
int aCount = c.Count(a => a == 'A'); //count all 'A' instances
int bCount = c.Count(b => b == 'B'); //count all 'B' instances
int cCount = c.Count(cc => cc == 'C'); //count all 'C' instances
int dCount = c.Count(d => d == 'D'); //count all 'D' instances
int eCount = c.Count(e => e == 'E'); //count all ''E' instances
int fCount = c.Count(f => f == 'F'); //count all 'F' instances
//
Console.WriteLine("\nA = {0}", aCount);
Console.WriteLine("B = {0}", bCount);
Console.WriteLine("C = {0}", cCount);
Console.WriteLine("D = {0}", dCount);
Console.WriteLine("E = {0}", eCount);
Console.WriteLine("F = {0}", fCount);
//multiplying amount in each group by 2
aCount = aCount * 2;
bCount = bCount * 2;
cCount = cCount * 2;
dCount = dCount * 2;
eCount = eCount * 2;
fCount = fCount * 2;
//outputs graph display
Console.WriteLine("\n0 10 20 30 40 50 60 70 80 90 100");
Console.WriteLine("| | | | | | | | | | |");
Console.WriteLine("**************************************************");
//outputs each grade according to the multiplied amount and is therefore displayed with asteriks
Console.Write(new String('*', aCount)); Console.Write(" A\n");
Console.Write(new String('*', bCount)); Console.Write(" B\n");
Console.Write(new String('*', cCount)); Console.Write(" C\n");
Console.Write(new String('*', dCount)); Console.Write(" D\n");
Console.Write(new String('*', eCount)); Console.Write(" E\n");
Console.Write(new String('*', fCount)); Console.Write(" F\n");
해결책
Open a a file "output.html" and write to this file, instead of your console. Obviously, you'll also want to write slightly different output, i.e. HTML markup etc. That's the solution to create a single web page from an otherwise console-style program.
If you want to create web page output on a regular basis, you should let the whole thing run in IIS and use ASP.NET such that you can automatically serve your output to a web request, and take advantage of, e.g., its HTML templating functions.
I know that's very general, but maybe it's a starting point from which you can either explore further or specify your problem!