Reputation: 5660
'X', here, is a 3rd-party component implementing ICollection, and 'Y' is Count. It compiles, temporarily removing the squigglies, and either shortly after (1-2 seconds), or after any edits are made in the text editor, shows red squigglies under Count. ?! Any help would be mucho appreciated, thx.
edit: for example,
ThirdPartyComponent instanceOfComponent = new instanceOfComponent();
instanceOfComponent.GetResults();
for(int i = 0; i < instanceOfComponent.Results.Count; ++i) {
// Some stuff happens
}
Here 'Count' is squigglied, even though it compiles fine--and even shows up in Intellisense.
Upvotes: 1
Views: 209
Reputation: 116438
From your comment above, it looks like VS is complaining about ambiguity between Results.Count
and Results.Count()
. It will compile fine, but it is warning you about this possible error. A cast to ICollection
will explicitly tell the compiler which one to use:
for(int i = 0; i < ((ICollection)instanceOfComponent.Results).Count; ++i)
Upvotes: 3
Reputation: 9209
I'm not sure what language you're using, but two possible problems here:
Count could be a function rather than a property.
More likely Results is actually a property returning a List<> based class and so you are calling the Count property of this Results object rather than the instanceOfComponent. A simple cast should solve it.
Upvotes: 0