.NET Framework Class Library
CultureInfoIsReadOnly Property

Gets a value indicating whether the current CultureInfo is read-only.

Namespace:   System.Globalization
Assemblies:   mscorlib (in mscorlib.dll)
  System.Globalization (in System.Globalization.dll)
Syntax
Public ReadOnly Property IsReadOnly As [%$TOPIC/53516z6s_en-us_VS_110_2_0_0_0_0%]
public [%$TOPIC/53516z6s_en-us_VS_110_2_0_1_0_0%] IsReadOnly { get; }
public:
property [%$TOPIC/53516z6s_en-us_VS_110_2_0_2_0_0%] IsReadOnly {
	[%$TOPIC/53516z6s_en-us_VS_110_2_0_2_0_1%] get ();
}
member IsReadOnly : [%$TOPIC/53516z6s_en-us_VS_110_2_0_3_0_0%] with get
function get IsReadOnly () : [%$TOPIC/53516z6s_en-us_VS_110_2_0_4_0_0%]

Property Value

Type: SystemBoolean
true if the current CultureInfo is read-only; otherwise, false. The default is false.
Remarks

If the CultureInfo is read-only, the DateTimeFormat and NumberFormat instances are also read-only.

Examples

The following code example shows that IsReadOnly also helps protect the DateTimeFormatInfo and NumberFormatInfo instances associated with the CultureInfo.

Imports System
Imports System.Globalization


Public Class SamplesCultureInfo

   Public Shared Sub Main()

      ' Creates a CultureInfo. 
      Dim myCI As New CultureInfo("en-US")

      ' Creates a read-only CultureInfo based on myCI. 
      Dim myReadOnlyCI As CultureInfo = CultureInfo.ReadOnly(myCI)

      ' Display the read-only status of each CultureInfo and their DateTimeFormat and NumberFormat properties. 
      If myCI.IsReadOnly Then 
         Console.WriteLine("myCI is read only.")
      Else
         Console.WriteLine("myCI is writable.")
      End If 

      If myCI.DateTimeFormat.IsReadOnly Then 
         Console.WriteLine("myCI.DateTimeFormat is read only.")
      Else
         Console.WriteLine("myCI.DateTimeFormat is writable.")
      End If 

      If myCI.NumberFormat.IsReadOnly Then 
         Console.WriteLine("myCI.NumberFormat is read only.")
      Else
         Console.WriteLine("myCI.NumberFormat is writable.")
      End If 

      If myReadOnlyCI.IsReadOnly Then 
         Console.WriteLine("myReadOnlyCI is read only.")
      Else
         Console.WriteLine("myReadOnlyCI is writable.")
      End If 

      If myReadOnlyCI.DateTimeFormat.IsReadOnly Then 
         Console.WriteLine("myReadOnlyCI.DateTimeFormat is read only.")
      Else
         Console.WriteLine("myReadOnlyCI.DateTimeFormat is writable.")
      End If 

      If myReadOnlyCI.NumberFormat.IsReadOnly Then 
         Console.WriteLine("myReadOnlyCI.NumberFormat is read only.")
      Else
         Console.WriteLine("myReadOnlyCI.NumberFormat is writable.")
      End If 

   End Sub 'Main 

End Class 'SamplesCultureInfo


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

*/
using namespace System;
using namespace System::Globalization;
int main()
{

   // Creates a CultureInfo.
   CultureInfo^ myCI = gcnew 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 ? (String^)"read only" : "writable" );
   Console::WriteLine( "myCI -> DateTimeFormat is {0}.", myCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" );
   Console::WriteLine( "myCI -> NumberFormat is {0}.", myCI->NumberFormat->IsReadOnly ? (String^)"read only" : "writable" );
   Console::WriteLine( "myReadOnlyCI is {0}.", myReadOnlyCI->IsReadOnly ? (String^)"read only" : "writable" );
   Console::WriteLine( "myReadOnlyCI -> DateTimeFormat is {0}.", myReadOnlyCI->DateTimeFormat->IsReadOnly ? (String^)"read only" : "writable" );
   Console::WriteLine( "myReadOnlyCI -> NumberFormat is {0}.", myReadOnlyCI->NumberFormat->IsReadOnly ? (String^)"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.
*/
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8