CultureInfo.ReadOnly 메서드
지정된 CultureInfo의 읽기 전용 래퍼를 반환합니다.
네임스페이스: System.Globalization
어셈블리: mscorlib(mscorlib.dll)
구문
‘선언
Public Shared Function ReadOnly ( _
ci As CultureInfo _
) As CultureInfo
‘사용 방법
Dim ci As CultureInfo
Dim returnValue As CultureInfo
returnValue = CultureInfo.ReadOnly(ci)
public static CultureInfo ReadOnly (
CultureInfo ci
)
public:
static CultureInfo^ ReadOnly (
CultureInfo^ ci
)
public static CultureInfo ReadOnly (
CultureInfo ci
)
public static function ReadOnly (
ci : CultureInfo
) : CultureInfo
매개 변수
- ci
래핑할 CultureInfo입니다.
반환 값
ci 주변의 읽기 전용 CultureInfo 래퍼입니다.
예외
예외 형식 | 조건 |
---|---|
ci이 Null 참조(Visual Basic의 경우 Nothing)인 경우 |
설명
이 래퍼는 ci 또는 ci.DateTimeFormat 및 ci.NumberFormat 속성에 의해 반환되는 개체를 수정할 수 없도록 합니다.
예제
다음 코드 예제에서는 CultureInfo와 연결된 DateTimeFormatInfo 및 NumberFormatInfo 인스턴스를 보호하는 ReadOnly 메서드를 보여 줍니다.
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.
*/
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 for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.
버전 정보
.NET Framework
2.0, 1.1, 1.0에서 지원
.NET Compact Framework
2.0, 1.0에서 지원
참고 항목
참조
CultureInfo 클래스
CultureInfo 멤버
System.Globalization 네임스페이스
IsReadOnly