CSharpTest.Net
Clear Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Clear Method

Glossary Item Box

Clears all elements from the collection

Syntax

Visual Basic (Declaration) 
Public Sub Clear() 
C# 
public void Clear()

Example

Library/Library.Test/TestUserSettings.cs

C#Copy Code
UserSettingsSubSection a;
UserSettingsSubSectionCollection coll1 = new UserSettingsSubSectionCollection();
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType);

Assert.IsNull(coll1["a"]);
a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

coll1.Remove("a");
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);
coll1.Clear();
Assert.IsNull(coll1["a"]);

a = coll1.Add("a");
Assert.AreEqual(a, coll1["a"]);

UserSettingsSubSectionCollection other = new UserSettingsSubSectionCollection();
other.CopyFrom(coll1);

Assert.IsNotNull(other["a"]);
Assert.AreEqual("a", other["a"].Name);
VB.NETCopy Code
Dim a As UserSettingsSubSection
Dim coll1 As New UserSettingsSubSectionCollection()
Assert.AreEqual(ConfigurationElementCollectionType.AddRemoveClearMap, coll1.CollectionType)

Assert.IsNull(coll1("a"))
a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

coll1.Remove("a")
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))
coll1.Clear()
Assert.IsNull(coll1("a"))

a = coll1.Add("a")
Assert.AreEqual(a, coll1("a"))

Dim other As New UserSettingsSubSectionCollection()
other.CopyFrom(coll1)

Assert.IsNotNull(other("a"))
Assert.AreEqual("a", other("a").Name)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys