"<" operator error
Posted
by Nona Urbiz
on Stack Overflow
See other posts from Stack Overflow
or by Nona Urbiz
Published on 2009-07-16T20:38:07Z
Indexed on
2010/04/07
2:03 UTC
Read the original article
Hit count: 401
Why is the ( i < UniqueWords.Count ) expression valid in the for loop, but returns "CS0019 Operator '<' cannot be applied to operands of type 'int' and 'method group'" error when placed in my if? They are both string arrays, previously declared.
for (int i = 0;i<UniqueWords.Count;i++){
Occurrences[i] = Words.Where(x => x.Equals(UniqueWords[i])).Count();
Keywords[i] = UniqueWords[i];
if (i<UniqueURLs.Count) {rURLs[i] = UniqueURLs[i];}
}
EDITED to add declarations:
List<string> Words = new List<string>();
List<string> URLs = new List<string>();
//elements added like so. . . .
Words.Add (referringWords); //these are strings
URLs.Add (referringURL);
UniqueWords = Words.Distinct().ToList();
UniqueURLs = URLs.Distinct().ToList();
SOLVED. thank you, parentheses were needed for method .Count() I still do not fully understand why they are not always necessary.
Jon Skeet, thanks, I guess I don't understand what exactly the declarations are either then? You wanted the actual values assigned? They are pulled from an external source, but are strings.
I get it! Thanks. (the ()'s at least.)
© Stack Overflow or respective owner