Share via


ConfigurationSectionCollection.Keys Özellik

Tanım

Bu ConfigurationSectionCollection nesnede bulunan tüm ConfigurationSection nesnelerin anahtarlarını alır.

public:
 virtual property System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ Keys { System::Collections::Specialized::NameObjectCollectionBase::KeysCollection ^ get(); };
public override System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys { get; }
member this.Keys : System.Collections.Specialized.NameObjectCollectionBase.KeysCollection
Public Overrides ReadOnly Property Keys As NameObjectCollectionBase.KeysCollection

Özellik Değeri

NameObjectCollectionBase.KeysCollection Bu koleksiyondaki tüm bölümlerin anahtarlarını içeren bir nesne.

Örnekler

Aşağıdaki örnekte özelliğinin nasıl kullanılacağı gösterilmektedir Keys .

static void GetKeys()
{

    try
    {
        System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

        ConfigurationSectionCollection sections =
            config.Sections;

        foreach (string key in sections.Keys)
        {

            Console.WriteLine(
             "Key value: {0}", key);
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
Shared Sub GetKeys()

    Try
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        Dim sections _
        As ConfigurationSectionCollection = _
        config.Sections


        Dim key As String
        For Each key In sections.Keys


            Console.WriteLine("Key value: {0}", key)
        Next key


    Catch err As ConfigurationErrorsException
        Console.WriteLine(err.ToString())
    End Try
End Sub

Şunlara uygulanır

Ayrıca bkz.