ConfigurationElement.IsReadOnly ConfigurationElement.IsReadOnly ConfigurationElement.IsReadOnly ConfigurationElement.IsReadOnly Method

定義

ConfigurationElement オブジェクトが読み取り専用かどうかを示す値を取得します。Gets a value indicating whether the ConfigurationElement object is read-only.

public:
 virtual bool IsReadOnly();
public virtual bool IsReadOnly ();
abstract member IsReadOnly : unit -> bool
override this.IsReadOnly : unit -> bool
Public Overridable Function IsReadOnly () As Boolean

戻り値

ConfigurationElement オブジェクトが読み取り専用の場合は true。それ以外の場合は falsetrue if the ConfigurationElement object is read-only; otherwise, false.

IsReadOnly メソッドを使用する方法の例を次に示します。The following example shows how to use the IsReadOnly method. これはカスタムセクションで使用され、 falseを返します。It is used on a custom section and returns false.

// 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());
    }

}
' 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

注釈

システムは、変更できない構成要素を定義します。The system defines configuration elements that cannot be modified.

どの要素を変更できるかを判断するにIsReadOnlyは、メソッドを使用します。To determine which elements can be modified, use the IsReadOnly method.

適用対象