Partilhar via


ConfigurationSectionGroupCollection.Keys Propriedade

Definição

Obtém as chaves para todos os objetos ConfigurationSectionGroup contidos nesse objeto ConfigurationSectionGroupCollection.

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

Valor da propriedade

Um NameObjectCollectionBase.KeysCollection objeto que contém os nomes de todos os grupos de seções nesta coleção.

Exemplos

O exemplo de código a seguir mostra como usar a Keys propriedade .

// Get the collection keys i.e., the
// group names.
static void GetKeys()
{

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

        ConfigurationSectionGroupCollection groups =
            config.SectionGroups;

        foreach (string key in groups.Keys)
        {

            Console.WriteLine(
             "Key value: {0}", key);
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }
}
' Get the collection keys i.e., the
' group names.
Shared Sub GetKeys()
   
   Try
         Dim config _
       As System.Configuration.Configuration = _
       ConfigurationManager.OpenExeConfiguration( _
       ConfigurationUserLevel.None)

         Dim groups _
         As ConfigurationSectionGroupCollection = _
         config.SectionGroups

      Dim key As String
      For Each key In  groups.Keys
         
         Console.WriteLine("Key value: {0}", key)
      Next key
   
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub

Aplica-se a

Confira também