ConfigurationPropertyCollection.Clear メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ConfigurationPropertyCollection.Clear メソッドの意味・解説 

ConfigurationPropertyCollection.Clear メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

コレクションからすべての構成プロパティ オブジェクト削除します

名前空間: System.Configuration
アセンブリ: System.Configuration (system.configuration.dll 内)
構文構文

使用例使用例

Clear メソッド使用する方法の例を次に示します

' Clear the property.
' It deletes all the attributes of the
' configuration element represented by
' the property.
Public Sub ClearCollection()
   Properties.Clear()
End Sub 'ClearCollection

// Clear the property.
// It deletes all the attributes of the
// configuration element represented by
// the property.
public void ClearCollection()
{
    Properties.Clear();
}

上記メソッド呼び出して構成ファイル変更保存する方法の例を次に示します

' Clear a collection of elements.
Shared Sub ClearCollection()
   Try
      
      Dim customSection As CustomSection
      
         ' Get the current configuration file.
         Dim config As System.Configuration.Configuration
 = _
         ConfigurationManager.OpenExeConfiguration( _
         ConfigurationUserLevel.None)

         ' Get the custom section.
         customSection = _
         config.GetSection("CustomSection")

         customSection.ClearCollection()

         If Not customSection.IsReadOnly()
 Then
             customSection.SectionInformation.ForceSave = True
             config.Save(ConfigurationSaveMode.Full)
         End If
   
   Catch err As ConfigurationErrorsException
      Console.WriteLine(err.ToString())
   End Try
End Sub 'ClearCollection
 
// Clear a collection of elements.
static void ClearCollection()
{
    try
    {

        CustomSection customSection;

        // Get the current configuration file.
        System.Configuration.Configuration config =
                ConfigurationManager.OpenExeConfiguration(
                ConfigurationUserLevel.None);

        customSection =
            config.GetSection("CustomSection") as CustomSection;
        customSection.ClearCollection();

        if (!customSection.IsReadOnly())
        {
            customSection.SectionInformation.ForceSave = true;
            config.Save(ConfigurationSaveMode.Full);
        }

    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine(err.ToString());
    }

}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ConfigurationPropertyCollection クラス
ConfigurationPropertyCollection メンバ
System.Configuration 名前空間
ConfigurationProperty クラス
ConfigurationSection
ElementInformation
ConfigurationElementCollection クラス
ConfigurationElementCollectionType 列挙
ConfigurationElement クラス
ConfigurationSection


このページでは「.NET Framework クラス ライブラリ リファレンス」からConfigurationPropertyCollection.Clear メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からConfigurationPropertyCollection.Clear メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からConfigurationPropertyCollection.Clear メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

ConfigurationPropertyCollection.Clear メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ConfigurationPropertyCollection.Clear メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS