String.ToUpperInvariant 메서드

정의

고정 문화권의 대/소문자 규칙을 사용하여 대문자로 변환된 이 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 메서드. 메서드는 ToUpperInvariantToUpper(CultureInfo.InvariantCulture)동일합니다. 문자열 컬렉션이 사용자 인터페이스 컨트롤에서 예측 가능한 순서로 표시되어야 하는 경우 메서드를 사용하는 것이 좋습니다.

참고

이 메서드는 현재 instance 값을 수정하지 않습니다. 대신 현재 instance 모든 문자가 대문자로 변환되는 새 문자열을 반환합니다.

파일 이름, 명명된 파이프 또는 레지스트리 키와 같은 운영 체제 식별자의 소문자 또는 대문자 버전이 필요한 경우 또는 ToUpperInvariant 메서드를 ToLowerInvariant 사용합니다.

적용 대상

추가 정보