CSharpTest.Net
Item(String) Property
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.AppConfig Namespace > UserSettingsSubSectionCollection Class : Item(String) Property

name

Glossary Item Box

Returns the specified collection by name if it exists, or null if not found

Syntax

Visual Basic (Declaration) 
Public Overloads Shadows ReadOnly Property Item( _
   ByVal name As String _
) As UserSettingsSubSection
C# 
public new UserSettingsSubSection Item( 
   string name
) {get;}

Parameters

name

Example

Library/Library.Test/TestUserSettings.cs

C#Copy Code
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
UserSettingsSection section = UserSettingsSection.UserSettingsFrom(config);

section["a"] = "b";

UserSettingsSubSection sec2;
if (null == (sec2 = section.Sections["test.child"]))
    sec2 = section.Sections.Add("test.child");

sec2["a"] = "test.child.b";

config.Save();

UserSettingStorage store = new UserSettingStorage();

string value;
Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);

Assert.IsTrue(store.Read("test.child", "a", out value));
Assert.AreEqual("test.child.b", value);
VB.NETCopy Code
Dim config As Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal)
Dim section As UserSettingsSection = UserSettingsSection.UserSettingsFrom(config)

section("a") = "b"

Dim sec2 As UserSettingsSubSection
If Nothing = (sec2 = section.Sections("test.child")) Then
    sec2 = section.Sections.Add("test.child")
End If

sec2("a") = "test.child.b"

config.Save()

Dim store As New UserSettingStorage()

Dim value As String
Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Assert.IsTrue(store.Read("test.child", "a", value))
Assert.AreEqual("test.child.b", value)

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys