Gets a value indicating whether the ConfigurationElement object is read-only.
Assembly: System.Configuration (in System.Configuration.dll)
Syntax
true if the ConfigurationElement object is read-only; otherwise, false.
Public Overridable Function IsReadOnly As [%$TOPIC/ms134129_en-us_VS_110_2_0_0_0_0%]
public virtual [%$TOPIC/ms134129_en-us_VS_110_2_0_1_0_0%] IsReadOnly()
public:
virtual [%$TOPIC/ms134129_en-us_VS_110_2_0_2_0_0%] IsReadOnly()
abstract IsReadOnly : unit -> [%$TOPIC/ms134129_en-us_VS_110_2_0_3_0_0%]
override IsReadOnly : unit -> [%$TOPIC/ms134129_en-us_VS_110_2_0_3_0_1%]
Return Value
Type: SystemBooleantrue if the ConfigurationElement object is read-only; otherwise, false.
Examples
The following example shows how to use the IsReadOnly method. 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.
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());
}
}
Platforms
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.