Char.ToUpper Metoda
Definicja
Konwertuje wartość znaku Unicode na jego wielką literę.Converts the value of a Unicode character to its uppercase equivalent.
Przeciążenia
ToUpper(Char, CultureInfo) |
Konwertuje wartość określonego znaku Unicode na jego wielką literę jako odpowiednik przy użyciu określonych informacji o formatowaniu specyficznych dla kultury.Converts the value of a specified Unicode character to its uppercase equivalent using specified culture-specific formatting information. |
ToUpper(Char) |
Konwertuje wartość znaku Unicode na jego wielką literę.Converts the value of a Unicode character to its uppercase equivalent. |
ToUpper(Char, CultureInfo)
Konwertuje wartość określonego znaku Unicode na jego wielką literę jako odpowiednik przy użyciu określonych informacji o formatowaniu specyficznych dla kultury.Converts the value of a specified Unicode character to its uppercase equivalent using specified culture-specific formatting information.
public:
static char ToUpper(char c, System::Globalization::CultureInfo ^ culture);
public static char ToUpper (char c, System.Globalization.CultureInfo culture);
static member ToUpper : char * System.Globalization.CultureInfo -> char
Public Shared Function ToUpper (c As Char, culture As CultureInfo) As Char
Parametry
- c
- Char
Znak Unicode, który ma zostać przekształcony.The Unicode character to convert.
- culture
- CultureInfo
Obiekt, który dostarcza reguły dotyczące wielkości znaków z uwzględnieniem ustawień kulturowych.An object that supplies culture-specific casing rules.
Zwraca
Wielkie litery c
, zmodyfikowane zgodnie z culture
lub niezmienionej wartości c
Jeśli c
jest już wielką literą, nie ma wielkich liter ani nie jest literałem.The uppercase equivalent of c
, modified according to culture
, or the unchanged value of c
if c
is already uppercase, has no uppercase equivalent, or is not alphabetic.
Wyjątki
culture
to null
.culture
is null
.
Przykłady
Poniższy przykład konwertuje każdy znak w tablicy na jego wielką literę odpowiadającą kulturze en-US, kulturze niezmiennej i kulturze TR-TR.The following example converts each character in an array to its uppercase equivalent for the en-US culture, the invariant culture, and the tr-TR culture. W tym przykładzie wielkie litery dla każdej małe litery są identyczne dla wszystkich kultur, z wyjątkiem jednego przypadku.In this example, the uppercase equivalent of each lowercase letter is identical for all cultures except for one case. Małe litery "i" (U + 0069) są konwertowane na "I" (U + 0049) w kulturach en-US i Invariant, ale do "i" (U + 0130) w kulturze TR-TR.The lowercase "i" character (U+0069) converts to "I" (U+0049) in the en-US and invariant cultures, but to "İ" (U+0130) in the tr-TR culture.
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
CultureInfo[] cultures= { CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.InvariantCulture,
CultureInfo.CreateSpecificCulture("tr-TR") };
Char[] chars = {'ä', 'e', 'E', 'i', 'I' };
Console.WriteLine("Character en-US Invariant tr-TR");
foreach (var ch in chars) {
Console.Write(" {0}", ch);
foreach (var culture in cultures)
Console.Write("{0,12}", Char.ToUpper(ch, culture));
Console.WriteLine();
}
}
}
// The example displays the following output:
// Character en-US Invariant tr-TR
// ä Ä Ä Ä
// e E E E
// E E E E
// i I I İ
// I I I I
Imports System.Globalization
Module Example
Public Sub Main()
Dim cultures() As CultureInfo = { CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.InvariantCulture,
CultureInfo.CreateSpecificCulture("tr-TR") }
Dim chars() As Char = {"ä"c, "e"c, "E"c, "i"c, "I"c }
Console.WriteLine("Character en-US Invariant tr-TR")
For Each ch In chars
Console.Write(" {0}", ch)
For Each culture In cultures
Console.Write("{0,12}", Char.ToUpper(ch, culture))
Next
Console.WriteLine()
Next
End Sub
End Module
' The example displays the following output:
' Character en-US Invariant tr-TR
' ä Ä Ä Ä
' e E E E
' E E E E
' i I I İ
' I I I I
Uwagi
Użyj String.ToUpper do przekonwertowania ciągu na wielkie litery.Use String.ToUpper to convert a string to uppercase.
Zobacz też
- ToUpper(Rune, CultureInfo)
- ToLower(Rune, CultureInfo)
- CurrentCulture
- ToUpper()
- ToLower(Char, CultureInfo)
Dotyczy
ToUpper(Char)
Konwertuje wartość znaku Unicode na jego wielką literę.Converts the value of a Unicode character to its uppercase equivalent.
public:
static char ToUpper(char c);
public static char ToUpper (char c);
static member ToUpper : char -> char
Public Shared Function ToUpper (c As Char) As Char
Parametry
- c
- Char
Znak Unicode, który ma zostać przekształcony.The Unicode character to convert.
Zwraca
W Wielkiej litery c
lub niezmienionej wartości parametru c
if c
jest już wielkie litery, nie ma wielkich liter ani nie jest literałem.The uppercase equivalent of c
, or the unchanged value of c
if c
is already uppercase, has no uppercase equivalent, or is not alphabetic.
Przykłady
Poniższy przykład konwertuje każdy znak w tablicy na jego wielką literę.The following example converts each character in an array to its uppercase equivalent.
using System;
public class Example
{
public static void Main()
{
char[] chars = { 'e', 'E', '6', ',', 'ж', 'ä' };
foreach (var ch in chars)
Console.WriteLine("{0} --> {1} {2}", ch, Char.ToUpper(ch),
ch == Char.ToUpper(ch) ? "(Same Character)" : "" );
}
}
// The example displays the following output:
// e --> E
// E --> E (Same Character)
// 6 --> 6 (Same Character)
// , --> , (Same Character)
// ? --> ?
// ä --> Ä
Module Example
Public Sub Main()
Dim chars() As Char = { "e"c, "E"c, "6"c, ","c, "ж"c, "ä"c }
For Each ch In chars
Console.WriteLine("{0} --> {1} {2}", ch, Char.ToUpper(ch),
If(ch = Char.ToUpper(ch), "(Same Character)", ""))
Next
End Sub
End Module
' The example displays the following output:
' e --> E
' E --> E (Same Character)
' 6 --> 6 (Same Character)
' , --> , (Same Character)
' ж --> Ж
' ä --> Ä
Uwagi
Reguły wielkości liter są uzyskiwane z bieżącej kultury.Casing rules are obtained from the current culture.
Użyj String.ToUpper do przekonwertowania ciągu na wielkie litery.Use String.ToUpper to convert a string to uppercase.
Uwagi dotyczące wywoływania
Jak wyjaśniono w najlepszych rozwiązaniach dotyczących korzystania z ciągów, zalecamy uniknięcie wywoływania metod tworzenia wielkości liter i ciągów znaków, które zastępują wartości domyślne.As explained in Best Practices for Using Strings, we recommend that you avoid calling character-casing and string-casing methods that substitute default values. Zamiast tego należy wywoływać metody, które wymagają jawnego określenia parametrów.Instead, you should call methods that require parameters to be explicitly specified. Aby skonwertować znak na wielkie litery przy użyciu konwencji wielkości liter w bieżącej kulturze, wywołaj ToUpper(Char, CultureInfo) Przeciążenie metody wartością CurrentCulture dla culture
parametru.To convert a character to uppercase by using the casing conventions of the current culture, call the ToUpper(Char, CultureInfo) method overload with a value of CurrentCulture for its culture
parameter.