MembershipCollection question

G

GaryDean

The static MembershipCollection class appears to work different than other
collection classes...

MembershipUserCollection myUsers = new MembershipUserCollection();
myUsers = Membership.GetAllUsers();
MembershipUser myMember = myUsers.Item[0]; <---- no Item property

This collection has no Item property. Why? The only way I can reference an
individual member of this collection is to specify the string value of the
key field (in this case username).

Thanks,
Gary
 
C

Cowboy \(Gregory A. Beamer\)

It is designed to be used with the user name, so leaving it out is not as
strange as it might seem.

If you absolutely need an indexer, consider creating a custom provider and
have it call most of the underlying methods except add a publicly exposed
indexer.
 
S

Steven Cheng[MSFT]

Hi Gary,

As Gregory has mentioned here, since MembershipUser instances are mainly
identified through their username, and index based locator doesn't help
much in the collection, so the MembershipuserCollection class doesn't
implement the index based accessor. However, if you do need index based
access to a list of MembershipUser objects, you can use the
"MembershipUserCollection.CopyTo" method to copy the list into a
MembershipUser[] array and access them through index based pattern.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top