CultureInfo.IsReadOnly Property
.NET Framework 4.5
Gets a value indicating whether the current CultureInfo is read-only.
Namespace: System.Globalization
Assembly: mscorlib (in mscorlib.dll)
Property Value
Type: System.Booleantrue if the current CultureInfo is read-only; otherwise, false. The default is false.
If the CultureInfo is read-only, the DateTimeFormat and NumberFormat instances are also read-only.
The following code example shows that IsReadOnly also helps protect the DateTimeFormatInfo and NumberFormatInfo instances associated with the CultureInfo.
using System; using System.Globalization; public class SamplesCultureInfo { public static void Main() { // Creates a CultureInfo. CultureInfo myCI = new CultureInfo( "en-US" ); // Creates a read-only CultureInfo based on myCI. CultureInfo myReadOnlyCI = CultureInfo.ReadOnly( myCI ); // Display the read-only status of each CultureInfo and their DateTimeFormat and NumberFormat properties. Console.WriteLine( "myCI is {0}.", myCI.IsReadOnly ? "read only" : "writable" ); Console.WriteLine( "myCI.DateTimeFormat is {0}.", myCI.DateTimeFormat.IsReadOnly ? "read only" : "writable" ); Console.WriteLine( "myCI.NumberFormat is {0}.", myCI.NumberFormat.IsReadOnly ? "read only" : "writable" ); Console.WriteLine( "myReadOnlyCI is {0}.", myReadOnlyCI.IsReadOnly ? "read only" : "writable" ); Console.WriteLine( "myReadOnlyCI.DateTimeFormat is {0}.", myReadOnlyCI.DateTimeFormat.IsReadOnly ? "read only" : "writable" ); Console.WriteLine( "myReadOnlyCI.NumberFormat is {0}.", myReadOnlyCI.NumberFormat.IsReadOnly ? "read only" : "writable" ); } } /* This code produces the following output. myCI is writable. myCI.DateTimeFormat is writable. myCI.NumberFormat is writable. myReadOnlyCI is read only. myReadOnlyCI.DateTimeFormat is read only. myReadOnlyCI.NumberFormat is read only. */
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.