1. Assume you have the created the following Stream objects:
StreamReader inputFile = new StreamReader("quiz8");
StreamWriter outputFile = new StreamWriter("quiz8Reverse");
Write a complete C# program that will copy the contents of "quiz8" into the file "quiz8Reverse" where each line of the
file "quiz8" is written to "quiz8Reverse" in reverse order.
using System;
using System.IO;
namespace Quiz8
{
class Q8
{
static void Main(string[] args)
{
StreamReader inputFile = new StreamReader("quiz8");
StreamWriter outputFile = new StreamWriter("quiz8Reverse");
string input;
while ((input = inputFile.ReadLine()) != null)
{
for (int i = input.Length-1; i >= 0; i--)
{
outputFile.Write(input.Substring(i,1));
}
outputFile.WriteLine();
}
inputFile.Close();
outputFile.Close();
}
}
}