String.ToUpperInvariant 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
고정 문화권의 대/소문자 규칙을 사용하여 대문자로 변환된 이 String 개체의 복사본을 반환합니다.
public:
System::String ^ ToUpperInvariant();
public string ToUpperInvariant();
member this.ToUpperInvariant : unit -> string
Public Function ToUpperInvariant () As String
반환
현재 문자열에 해당하는 대문자입니다.
예제
다음 예제에서는 여러 언어로 된 단일 단어를 포함하는 문자열 배열을 정의합니다. 이 ToUpperInvariant 메서드는 병렬 배열의 요소를 각 단어의 대/소문자를 구분하지 않는 버전으로 채우는 데 사용됩니다. 이 Array.Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>) 메서드는 대문자 배열의 요소 순서에 따라 대/소문자를 구분하는 배열을 정렬하여 언어에 관계없이 요소가 동일한 순서로 표시되도록 하는 데 사용됩니다.
using System;
using System.IO;
public class Example
{
public static void Main()
{
string[] words = { "Tuesday", "Salı", "Вторник", "Mardi",
"Τρίτη", "Martes", "יום שלישי",
"الثلاثاء", "วันอังคาร" };
StreamWriter sw = new StreamWriter(@".\output.txt");
// Display array in unsorted order.
foreach (string word in words)
sw.WriteLine(word);
sw.WriteLine();
// Create parallel array of words by calling ToUpperInvariant.
string[] upperWords = new string[words.Length];
for (int ctr = words.GetLowerBound(0); ctr <= words.GetUpperBound(0); ctr++)
upperWords[ctr] = words[ctr].ToUpperInvariant();
// Sort the words array based on the order of upperWords.
Array.Sort(upperWords, words, StringComparer.InvariantCulture);
// Display the sorted array.
foreach (string word in words)
sw.WriteLine(word);
sw.Close();
}
}
// The example produces the following output:
// Tuesday
// Salı
// Вторник
// Mardi
// Τρίτη
// Martes
// יום שלישי
// الثلاثاء
// วันอังคาร
//
// Mardi
// Martes
// Salı
// Tuesday
// Τρίτη
// Вторник
// יום שלישי
// الثلاثاء
// วันอังคาร
open System
open System.IO
do
let words =
[| "Tuesday"; "Salı"; "Вторник"; "Mardi"
"Τρίτη"; "Martes"; "יום שלישי"
"الثلاثاء"; "วันอังคาร" |]
use sw = new StreamWriter(@".\output.txt")
// Display array in unsorted order.
for word in words do
sw.WriteLine word
sw.WriteLine()
// Create parallel array of words by calling ToUpperInvariant.
let upperWords = words |> Array.map (fun x -> x.ToUpperInvariant())
// Sort the words array based on the order of upperWords.
Array.Sort(upperWords, words, StringComparer.InvariantCulture)
// Display the sorted array.
for word in words do
sw.WriteLine word
sw.Close()
// The example produces the following output:
// Tuesday
// Salı
// Вторник
// Mardi
// Τρίτη
// Martes
// יום שלישי
// الثلاثاء
// วันอังคาร
//
// Mardi
// Martes
// Salı
// Tuesday
// Τρίτη
// Вторник
// יום שלישי
// الثلاثاء
// วันอังคาร
Imports System.IO
Module Example
Public Sub Main()
Dim words() As String = { "Tuesday", "Salı", "Вторник", "Mardi", _
"Τρίτη", "Martes", "יום שלישי", _
"الثلاثاء", "วันอังคาร" }
Dim sw As New StreamWriter(".\output.txt")
' Display array in unsorted order.
For Each word As String In words
sw.WriteLine(word)
Next
sw.WriteLine()
' Create parallel array of words by calling ToUpperInvariant.
Dim upperWords(words.Length - 1) As String
For ctr As Integer = words.GetLowerBound(0) To words.GetUpperBound(0)
upperWords(ctr) = words(ctr).ToUpperInvariant()
Next
' Sort the words array based on the order of upperWords.
Array.Sort(upperWords, words, StringComparer.InvariantCulture)
' Display the sorted array.
For Each word As String In words
sw.WriteLine(word)
Next
sw.Close()
End Sub
End Module
' The example produces the following output:
' Tuesday
' Salı
' Вторник
' Mardi
' Τρίτη
' Martes
' יום שלישי
' الثلاثاء
' วันอังคาร
'
' Mardi
' Martes
' Salı
' Tuesday
' Τρίτη
' Вторник
' יום שלישי
' الثلاثاء
' วันอังคาร
설명
"불변 문화는 문화적 차이에 영향을 받지 않는 문화를 나타냅니다." 영어와 연결되지만 특정 국가 또는 지역과는 연결되지 않습니다. 자세한 내용은 CultureInfo.InvariantCulture 속성을 참조하세요.
애플리케이션이 현재 문화권의 영향을 받지 않는 예측 가능한 방식으로 변경되는 문자열의 경우에 따라 달라지는 경우 이 메서드를 ToUpperInvariant 사용합니다. 메서드는 ToUpperInvariant .에 해당합니다 ToUpper(CultureInfo.InvariantCulture). 문자열 컬렉션이 사용자 인터페이스 컨트롤에서 예측 가능한 순서로 표시되어야 하는 경우 이 메서드를 사용하는 것이 좋습니다.
메모
이 메서드는 현재 인스턴스의 값을 수정하지 않습니다. 대신 현재 인스턴스의 모든 문자가 대문자로 변환되는 새 문자열을 반환합니다.
파일 이름, 명명된 파이프 또는 레지스트리 키와 같은 운영 체제 식별자의 소문자 또는 대문자 버전이 필요한 경우 해당 또는 ToUpperInvariant 메서드를 사용합니다ToLowerInvariant.