Redigera

Dela via


MembershipUserCollection.SetReadOnly Method

Definition

Makes the contents of the membership user collection read-only.

public:
 void SetReadOnly();
public void SetReadOnly ();
member this.SetReadOnly : unit -> unit
Public Sub SetReadOnly ()

Examples

The following code example returns all of the users from the membership data store. The MembershipUserCollection returned is marked as read-only based on a Boolean parameter specified by the caller.

public MembershipUserCollection GetUsers(bool setReadOnly)
{
  MembershipUserCollection users = Membership.GetAllUsers();
  if (setReadOnly)
    users.SetReadOnly();
  return users;
}
Public Function GetUsers(setReadOnly As Boolean) As MembershipUserCollection 
  Dim users As MembershipUserCollection = Membership.GetAllUsers()
  If setReadOnly Then users.SetReadOnly()
  Return users
End Function

Remarks

The contents of a MembershipUserCollection are considered read-only, as they are a snapshot of the membership user information in the membership data store. Membership user information is modified using the UpdateUser, CreateUser and DeleteUser methods. The SetReadOnly method marks the MembershipUserCollection as read-only so that MembershipUser objects cannot be added to or removed from the collection. Property values for the MembershipUser objects are not marked as read-only. That is, you can modify the property values of a MembershipUser in the MembershipUserCollection regardless of whether the collection has been marked as read-only by the SetReadOnly method.

Applies to

See also