Returns a copy of this String object converted to uppercase using the casing rules of the invariant culture.
public:
System::String ^ ToUpperInvariant();
public string ToUpperInvariant();
member this.ToUpperInvariant : unit -> string
Public Function ToUpperInvariant () As String
Returns
The uppercase equivalent of the current string.
ExamplesThe following example defines a string array that contains a single word in a number of languages. The ToUpperInvariant method is used to populate the elements of a parallel array with the case-insensitive version of each word. The Array.Sort<TKey,TValue>(TKey[], TValue[], IComparer<TKey>) method is used to sort the case-sensitive array based on the order of elements in the uppercase array to ensure that elements appear in the same order regardless of language.
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
' ΤÏίÏη
' ÐÑоÑник
' ××× ×©××ש×
' Ø§ÙØ«Ùاثاء
' วัà¸à¸à¸±à¸à¸à¸²à¸£
Remarks
The invariant culture represents a culture that is culture-insensitive. It is associated with the English language but not with a specific country or region. For more information, see the CultureInfo.InvariantCulture property.
If your application depends on the case of a string changing in a predictable way that is unaffected by the current culture, use the ToUpperInvariant method. The ToUpperInvariant method is equivalent to ToUpper(CultureInfo.InvariantCulture)
. The method is recommended when a collection of strings must appear in a predictable order in a user interface control.
Note
This method does not modify the value of the current instance. Instead, it returns a new string in which all characters in the current instance are converted to uppercase.
If you need the lowercase or uppercase version of an operating system identifier, such as a file name, named pipe, or registry key, use the ToLowerInvariant or ToUpperInvariant methods.
See alsoRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4