Visual Studio 2008 SP1:
"X", here, is a 3rd party component that implements ICollection, and "Y" is Count. It compiles by temporarily removing the squigglies and either shortly after (1-2 seconds) or after making any changes in the text editor it shows red squigglies under Count.?! Any help would be greatly appreciated, thanks.
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, although it compiles fine - and even shows up in Intellisense.
a source to share
From your comment above, it looks like VS is complaining about the ambiguity between Results.Count
and Results.Count()
. It will compile just fine, but it warns you about this possible error. Casting to ICollection
will explicitly tell the compiler which one to use:
for(int i = 0; i < ((ICollection)instanceOfComponent.Results).Count; ++i)
a source to share
I'm not sure which language you are using, but there are two possible problems here:
-
Count can be a function, not a property.
-
Most likely, the results are a property that returns a class based on List <> and so you are calling the Count property of this Results object, not instanceOfComponent. A simple casting should solve it.
a source to share