Esporta (0) Stampa
Espandi tutto

Proprietà CultureInfo.IsReadOnly

Ottiene un valore che indica se la classe CultureInfo corrente è in sola lettura.

Spazio dei nomi: System.Globalization
Assembly: mscorlib (in mscorlib.dll)

public bool IsReadOnly { get; }
/** @property */
public boolean get_IsReadOnly ()

public function get IsReadOnly () : boolean

Valore proprietà

true se la classe CultureInfo corrente è in sola lettura; in caso contrario false. Il valore predefinito è false.

Se la classe CultureInfo è in sola lettura, anche le istanze di DateTimeFormat e di NumberFormat sono in sola lettura.

Nell'esempio di codice riportato di seguito viene mostrato come tramite la proprietà IsReadOnly sia anche possibile proteggere le istanze DateTimeFormatInfo e NumberFormatInfo associate all'oggetto 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.

*/

import System.* ;
import System.Globalization.* ;

public class SamplesCultureInfo
{
    public static void main(String[] args)
    {
        // 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.get_IsReadOnly() ) ? "read only" : "writable");
        Console.WriteLine("myCI.DateTimeFormat is {0}.",
            (myCI.get_DateTimeFormat().get_IsReadOnly()) ? 
            "read only" : "writable");
        Console.WriteLine("myCI.NumberFormat is {0}.",(
            myCI.get_NumberFormat().get_IsReadOnly()) ? 
            "read only" : "writable");
        Console.WriteLine("myReadOnlyCI is {0}.",
            (myReadOnlyCI.get_IsReadOnly()) ? "read only" : "writable");
        Console.WriteLine("myReadOnlyCI.DateTimeFormat is {0}.",
            (myReadOnlyCI.get_DateTimeFormat().get_IsReadOnly()) ? 
            "read only" : "writable");
        Console.WriteLine("myReadOnlyCI.NumberFormat is {0}.",
            (myReadOnlyCI.get_NumberFormat().get_IsReadOnly()) ? 
            "read only" : "writable");
    } //main 
} //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.
*/

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework non supporta tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema.

.NET Framework

Supportato in: 2.0 1.1 1.0

.NET Compact Framework

Supportato in: 2.0 1.0

Aggiunte alla community

AGGIUNGI
Microsoft sta conducendo un sondaggio in linea per comprendere l'opinione degli utenti in merito al sito Web di MSDN. Se si sceglie di partecipare, quando si lascia il sito Web di MSDN verrà visualizzato il sondaggio in linea.

Si desidera partecipare?
Mostra:
© 2014 Microsoft