TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Adam Rayborn
NA
6
4.7k
Build Errors
Dec 9 2008 11:44 PM
I am getting a couple of build errors in my code.
The first of which is:
'wordFreq' is a 'variable' but is used like a 'method'
it says that on the line:
wordFreq(words[i].ToLower()) += 1;
I am also getting an error that says:
The name ' i ' does not exist in the current context
Here is my code:
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);
Hashtable wordFreq = new Hashtable();
foreach (string word in words)
{
if (words[i] != "")
{
bool realWord = true;
for (int j = 0; j < words[i].Length; j++)
{
if (char.IsLetter(words[i][j]) == false)
{
realWord = false;
}
}
if (realWord == true)
{
if (wordFreq.Contains(words[i].ToLower()))
{
wordFreq(words[i].ToLower()) += 1;
}
else
{
wordFreq.Add(words[i].ToLower(), 1);
}
}
}
}
SortedList wordCount = new SortedList();
foreach (DictionaryEntry de in wordFreq)
{
if (wordCount.ContainsKey(de.Value) == false)
{
wordCount.Add(de.Value, de.Key);
}
}
}
}
}
Reply
Answers (
3
)
Create Exchange 2007 Transport Agent
convert image from encrypted image