1
Answer

C# Question

Adam Rayborn

Adam Rayborn

15y
2k
1
Well,

Here is what I need to do: 

I need to split the text from a .txt file into a list of the words in the file (which I have done)  I then need to count each word and list them so that there are no repeating words in the list ( each word appears only one with a number next to it representing how many times it occurs).  I am assuming I can use a hashtable for this but don't know where to begin.

The next thing I need to do is, perform an http request and find the top 5 google searched for the 3 words that appear the most and display the results.

Here is what i have so far:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using System.Collections;

namespace ConsoleApplication2
{
    class SplitTextFile
    {
        static void Main(string[] args)
        {
            FileStream file = new FileStream("input.txt", FileMode.OpenOrCreate, FileAccess.Read);
            StreamReader sr = new StreamReader(file);
            string s = sr.ReadToEnd();
            sr.Close();
            file.Close();
            char[] delim = { ' ', '\t', '\r', '\n' };
            string[] words = s.Split(delim);
            foreach (string word in words)
            {
                Console.WriteLine(word);
            }
            Console.ReadLine();
        }
    }
   
}

Answers (1)