Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[HELP] C# Homework 2. LearnVisualStudio [HELP]
#1
Alright so long story short I am extremely new to this and refuse to cheat so throw hints at me not answers. This should be super easy, here is the assignment.

I have a .txt file that is named "DecodeThis.txt" It's simply a .txt with the words backwards. So I know I need to read this file and then flip it using Array.Reverse. I don't know how and when to apply this though. So here is what I have so far.


I just don't know how to apply the arrays..

Not sure if that's right and I'm not sure where to put it.. Huh

Any tips that aren't answers?


--EDIT--

Alright here is the closest I've gotten but it's still wrong.

-Polite-Active-Respectful-Atheist-Donator-Obliging-xerox?-
Are you trolling me? I don't care. Your thread may help someone that was too embarrassed to ask.
Reply
#2
(10-28-2010, 12:04 AM)-paradox- Wrote: --EDIT--

Alright here is the closest I've gotten but it's still wrong.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Homework_Day_2
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader myReader = new StreamReader("DecodeThis.txt");
            String line = "";


            while (line != null)
            {
                line = myReader.ReadLine();
                if (line != null)
                    Console.WriteLine(line);
            }
            
            string Streamreader = ("DecodeThis.txt");
            char[] charArray = myReader.ToCharArray();
            Array.Reverse(charArray);
            Console.WriteLine(charArray);

          
            myReader.Close();
            Console.ReadLine();


        }
    }
}

You need to take this one step at a time. Everything is going to take place in your while () loop. And you aren't going to be converting the stream to a char array, but rather the output from the stream (look at your current while loop).

Also, you'll want to revise the conditional of your while loop. StreamReader objects have an EndOfStream property, which returns a boolean (true if it's at the end of the stream). So if you make your while loop's invariant "while EndOfStream is not true", you won't need to worry about reading in a line that doesn't exist.
Ho, ho, ho! Well, if it isn't fat stinking billy goat Billy Boy in poison!
How art thou, thou globby bottle of cheap, stinking chip oil?
Come and get one in the yarbles, if ya have any yarbles, you eunuch jelly thou!
Reply
#3

Well I got this part of it. Thanks for replying by the way, I really appreciate it. I have a feeling I'll need a lot of help in the future as well. I'm going to go through lesson two and hopefully figure this out first try next time. I'll implement the making a new .txt the next time around.
-Polite-Active-Respectful-Atheist-Donator-Obliging-xerox?-
Are you trolling me? I don't care. Your thread may help someone that was too embarrassed to ask.
Reply
#4
I need help with this again.. I'm not sure what's missing or what is wrong but when I run it, it creates the .txt just fine but doesn't actually put in the decrypted message. I'm aware there may be other messages but this is what I've learned so far and this is what I'm required to use.


-Polite-Active-Respectful-Atheist-Donator-Obliging-xerox?-
Are you trolling me? I don't care. Your thread may help someone that was too embarrassed to ask.
Reply
#5
(10-28-2010, 06:40 PM)-paradox- Wrote: I need help with this again.. I'm not sure what's missing or what is wrong but when I run it, it creates the .txt just fine but doesn't actually put in the decrypted message. I'm aware there may be other messages but this is what I've learned so far and this is what I'm required to use.



What you have there should work. Are you looking for it in the correct spot? The file should be created inside the project folder - bin - Debug directory. Alternatively you could force it to save the file to the desktop.

Code:
StreamWriter myWriter = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\decoded.txt");
Ho, ho, ho! Well, if it isn't fat stinking billy goat Billy Boy in poison!
How art thou, thou globby bottle of cheap, stinking chip oil?
Come and get one in the yarbles, if ya have any yarbles, you eunuch jelly thou!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)