"<" operator error
- by Nona Urbiz
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.)