获取会员用户和电子邮件

Get Membership Users and Emails

我很难理解 MembershipUserCollection 的结构 class。例如,我将所有用户作为 MembershipUserCollection 获取,但我无法访问 MembershipUser 以获取用户电子邮件。这是我目前所做的示例:

 MembershipUserCollection AllUsers = Membership.GetAllUsers();
 foreach (var user in AllUsers)
   {
     var userName = user.ToString();
     // Is there a better way to get the email within loop without having to call the GetUser method??
     var email = Membership.GetUser(user).Email 
   }

尝试使用

foreach (MembershipUser user in AllUsers)