Reputation: 12417
What happend to my Intellisense??
When I type a line like this ...
Dim users = (From u In Membership.GetAllUsers Select u.UserName)
... I get (almost) no Intellisense when I get to the Select u.
part. Only Equals, GetHashCode, GetType, ReferenceEquals and ToString appears. Not "UserName" and the other relevant propeties of the MembershipUser class.
The code compiles and works just fine.
Any suggestions?
I tried devenv.exe /ResetSettings
from the VS Command prompt as suggested in this question, but it didn't help.
Upvotes: 2
Views: 1455
Reputation: 4349
What JaredPar told you is true , because that collection is not IEnumerable
so you have to tell the compiler which object type inside your collection
And if that still not working be sure that you imported the linq namespace in the top of the class
Import System.Linq
:)
Upvotes: 0
Reputation: 755151
The reason why this is happening is because the return type of MemberShip.GetAllUsers
is MembershipUserCollection
. This collection type only implements IEnumerable
and is not strongly type. The compiler can only infer the type of the elements in the collection is Object
. Hence you get intellisense for Object
in the select clause.
You need to tell the compiler more information about the type of the elements. For instance if you know all of the values are MembershipUser
instances you could use the Cast function to tell the compiler
From u in Membership.GetAllUsers().Cast(Of MembershipUser) ...
Upvotes: 2