how VAR is determined against many options?

Posted by Royi Namir on Stack Overflow See other posts from Stack Overflow or by Royi Namir
Published on 2012-06-22T15:11:41Z Indexed on 2012/06/22 15:16 UTC
Read the original article Hit count: 210

i have this code :

IEnumerable<string> q = customers /*EF entity*/
.Select (c => c.Name.ToUpper())
.OrderBy (n => n)

To select entity, ObjectContext actually create ObjectQuery, which implement IQueryable. The object return from ObjectQuery, is not normal object, but EntityObject

but what if i write : ( notice the var)

var q = customers /*EF entity*/
.Select (c => c.Name.ToUpper())
.OrderBy (n => n)

it can be determined both to ienumerable or iqueryable :

because ObjectQuery Also implements IEnumerable...

i dont know if there's any specific info which tell the compiler "use A and not B. A is more specific..." ( there must be...i just cant find it)

enter image description here

any help ? how will it know to use A || B ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET