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

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

ConfigurationElement.IsReadOnly メソッド

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

ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。

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

Public Overridable Function
 IsReadOnly As Boolean
Dim instance As ConfigurationElement
Dim returnValue As Boolean

returnValue = instance.IsReadOnly
public virtual bool IsReadOnly ()
public:
virtual bool IsReadOnly ()
public boolean IsReadOnly ()

戻り値
ConfigurationElement オブジェクトが読み取り専用の場合は true。それ以外の場合は false。

解説解説

システムによって定義されている構成要素は、変更できません。

変更できる要素を確認するには、IsReadOnly メソッドを使用します。

使用例使用例

IsReadOnly メソッドを使用する方法の例を次に示します。これは、カスタム セクションで使用され、false を返します。

' Show how to use IsReadOnly.
' It loops to see if the elements are read only. 
Shared Sub ReadOnlyElements() 
    Try
        ' Get the current configuration file.
        Dim config _
        As System.Configuration.Configuration = _
        ConfigurationManager.OpenExeConfiguration( _
        ConfigurationUserLevel.None)

        ' Get the MyUrls section.
        Dim myUrlsSection As UrlsSection =
 _
        config.GetSection("MyUrls")
        
        Dim elements As UrlsCollection = _
        myUrlsSection.Urls
                   
        Dim elemEnum As IEnumerator = _
        elements.GetEnumerator()
        
        Dim i As Integer
 = 0
        Console.WriteLine(elements.Count.ToString())
        
        While elemEnum.MoveNext()
            Console.WriteLine("The element {0} is read only: {1}",
 _
            elements(i).Name, elements(i).IsReadOnly().ToString())
            i += 1
        End While
    Catch err As ConfigurationErrorsException
        Console.WriteLine("[ReadOnlyElements: {0}]",
 _
        err.ToString())
    End Try

End Sub 'ReadOnlyElements

// Show how to use IsReadOnly.
// It loops to see if the elements are read only. 
static void ReadOnlyElements()
{
    try
    {
        // Get the configuration file.
        System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

        // Get the MyUrls section.
        UrlsSection myUrlsSection =
            config.GetSection("MyUrls") as UrlsSection;


        UrlsCollection elements = myUrlsSection.Urls;


        IEnumerator elemEnum =
            elements.GetEnumerator();

        int i = 0;
        Console.WriteLine(elements.Count.ToString());

        while (elemEnum.MoveNext())
        {
            Console.WriteLine("The element {0} is read only: {1}",
             elements[i].Name, 
             elements[i].IsReadOnly().ToString());
            i += 1;
        }
    }
    catch (ConfigurationErrorsException err)
    {
        Console.WriteLine("[ReadOnlyElements: {0}]",
            err.ToString());
    }

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



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



ConfigurationElement.IsReadOnly メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS