I am using Visual Studio C# 2010.
I am working on a homework assignment and need a little help. I am not necessarily looking for the answer, but for some guidance to figure out what I am doing wrong. I had to write a program that took a txt file. (DecodeThis.txt) and write it to the screen, but it was also written backwards. This is the code I used to accomplish this:
Then I needed to write this reversed text to a text file. This is where I am stumped. I looked up an article on MSDN but when I tried that approach I couldn't get it to work. Here is what I tried:Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Day2Homework { class Program { static void Main(string[] args) { StreamReader myReader = newStreamReader("DecodeThis.txt"); string line = ""; while (line != null) { line = myReader.ReadLine(); if (line != null) { char[] charArray = line.ToCharArray(); Array.Reverse(charArray); Console.WriteLine(charArray); } } myReader.Close(); Console.ReadLine(); } } }
the compiler is telling me that char does not have a definition for name. Where do I go from here? Am I close?Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace Day2Homework { class Program { static void Main(string[] args) { StreamReader myReader = new StreamReader("DecodeThis.txt"); string line = ""; while (line != null) { line = myReader.ReadLine(); if (line != null) { char[] charArray = line.ToCharArray(); Array.Reverse(charArray); using (StreamWriter sw = new StreamWriter("Decoded.txt")) { foreach(char array in charArray) sw.WriteLine(array.Name); } } } myReader.Close(); Console.ReadLine(); } } }
Thanks in advance




Reply With Quote