JanSte (5) [Avatar] Offline
#1
I've just tried the 10.8 Example and the .Where(...) doesn't work, It returns a bool instead of a int. There is 2 overloads, if I use this instead it works
.Where((x, i) => x%2 != 0)

/ Jan
tomten (19) [Avatar] Offline
#2
Re: 10.3.2 .Where and overloads
> I've just tried the 10.8 Example and the .Where(...) doesn't work (...)

Works fine here. Do you have meapch13?
mgravell (64) [Avatar] Offline
#3
Re: 10.3.2 .Where and overloads
Listing 10.8? It works fine for me... in my version the Where is:

.Where(x => x%2 != 0);
tomten (19) [Avatar] Offline
#4
Re: 10.3.2 .Where and overloads
> in my version

If you specify which version of the book you have, it will make things less confusing. I suspect the OP doesn't have meapch13, for example. And your version matches the one in meapch13, so I suspect you do.
JanSte (5) [Avatar] Offline
#5
Re: 10.3.2 .Where and overloads
Found it. I have lot of examples in my project, and this causes the problem
public static IEnumerable<bool> Where<T>(this IEnumerable<T> list, Func<int, bool> f) {...);
It's my own overload that causes the problem

Thanks for the help guys.
smilie

/ Jan
mgravell (64) [Avatar] Offline
#6
Re: 10.3.2 .Where and overloads
As I recall, the only other MEAP version was chapters 1-9; since this doesn't include the cited section, I felt it redundant.
tomten (19) [Avatar] Offline
#7
Re: 10.3.2 .Where and overloads
> It's my own overload that causes the problem

I guess you could say that we have a case of "overload overload" here.
mgravell (64) [Avatar] Offline
#8
Re: 10.3.2 .Where and overloads
>It's my own overload that causes the problem
Very easily done.
The issue of extension resolution is one that I know Jon is painfully aware of (see his recent blog entries on msmvps).

It doesn't help that intellisense doesn't make it obvious where it is coming from; however, F12, or "go to definition" both indicate this oh-so-important detail.
jon.skeet (448) [Avatar] Offline
#9
Re: 10.3.2 .Where and overloads
I'd just like to thank my support team for all their efforts smilie