The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
CultureInfo::ReadOnly Method (CultureInfo^)
.NET Framework (current version)
Returns a read-only wrapper around the specified CultureInfo object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- ci
-
Type:
System.Globalization::CultureInfo^
The CultureInfo object to wrap.
| Exception | Condition |
|---|---|
| ArgumentNullException | ci is null. |
This wrapper prevents any modifications to ci, or the objects returned by the ci.DateTimeFormat and ci.NumberFormat properties.
The following example shows that the ReadOnly method helps protect the DateTimeFormatInfo and NumberFormatInfo instances associated with the CultureInfo.
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. */
Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Show: