次の方法で共有


CultureInfo.IsReadOnly プロパティ

現在の CultureInfo が読み取り専用かどうかを示す値を取得します。

Public ReadOnly Property IsReadOnly As Boolean
[C#]
public bool IsReadOnly {get;}
[C++]
public: __property bool get_IsReadOnly();
[JScript]
public function get IsReadOnly() : Boolean;

プロパティ値

現在の CultureInfo が読み取り専用の場合は true 。それ以外の場合は false 。既定値は false です。

解説

CultureInfo が読み取り専用の場合、 DateTimeFormat のインスタンスと NumberFormat のインスタンスも読み取り専用です。

使用例

[Visual Basic, C#, C++] 次のコード例は、CultureInfo.ReadOnly が、 CultureInfo に関連付けられている DateTimeFormatInfo インスタンスと NumberFormatInfo インスタンスも保護することを示しています。

 
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.

[C#] 
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.

*/

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Globalization;

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

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET

参照

CultureInfo クラス | CultureInfo メンバ | System.Globalization 名前空間 | ReadOnly