ProfileGroupSettingsCollection.Add(ProfileGroupSettings) Metod

Definition

Lägger till ett ProfileGroupSettings objekt i samlingen.

public:
 void Add(System::Web::Configuration::ProfileGroupSettings ^ group);
public void Add(System.Web.Configuration.ProfileGroupSettings group);
member this.Add : System.Web.Configuration.ProfileGroupSettings -> unit
Public Sub Add (group As ProfileGroupSettings)

Parametrar

group
ProfileGroupSettings

Ett ProfileGroupSettings objekt som ska läggas till i samlingen.

Undantag

Objektet ProfileGroupSettings som ska läggas till finns redan i samlingen, eller så är samlingen skrivskyddad.

Exempel

I följande kodexempel visas hur metoden Add används. Det här kodexemplet är en del av ett större exempel för ProfileSection klassen.

// Add a new group.
ProfileGroupSettings newPropGroup = new ProfileGroupSettings("Forum");
profileSection.PropertySettings.GroupSettings.Add(newPropGroup);

// Add a new PropertySettings to the group.
ProfilePropertySettings newProp = new ProfilePropertySettings("AvatarImage");
newProp.Type = "System.String, System.dll";
newPropGroup.PropertySettings.Add(newProp);

// Remove a PropertySettings from the group.
newPropGroup.PropertySettings.Remove("AvatarImage");
newPropGroup.PropertySettings.RemoveAt(0);

// Clear all PropertySettings from the group.
newPropGroup.PropertySettings.Clear();
' Add a new group.
Dim newPropGroup As ProfileGroupSettings = new ProfileGroupSettings("Forum")
profileSection.PropertySettings.GroupSettings.Add(newPropGroup)

' Add a new PropertySettings to the group.
Dim newProp As ProfilePropertySettings = new ProfilePropertySettings("AvatarImage")
newProp.Type = "System.String, System.dll"
newPropGroup.PropertySettings.Add(newProp)

' Remove a PropertySettings from the group.
newPropGroup.PropertySettings.Remove("AvatarImage")
newPropGroup.PropertySettings.RemoveAt(0)

' Clear all PropertySettings from the group.
newPropGroup.PropertySettings.Clear()

Kommentarer

Samlingen får inte redan innehålla ett ProfileGroupSettings objekt med samma namn.

Gäller för

Se även