Char.ToUpper 没有大写形式时
Char.ToUpper When There Is No Upper Case Form
转换 to/from 驼峰式大小写的编写方法 我有一个想法 - 如果有人使用没有大写形式的 Unicode 字符出现并通过我的函数运行它怎么办?如果有人将已经大写的 'A'
传递给 Char.ToUpper
怎么办?我检查了参考源,它只是引导到一个 DllImport - 我知道核心 CLR 源是可用的,但我不是很擅长导航它(我认为它组织得不好,但也许我只是不明白逻辑).
当你将这些东西传递给那个函数时会发生什么?我知道我可以测试它,但是有没有像这样的情况发生故障?任何抛出异常或导致任何类型的失败或意外行为的东西?我希望该函数在任何情况下都将 return 原始字符转换为大写字母无效,但情况是这样吗?
这记录在 Char.ToUpper method documentation on MSDN 中 return 值下的方法:
The uppercase equivalent of c, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.
所以它不会中断,它只是return你调用方法的字符,不变。
根据MSDN它returns:
The uppercase equivalent of c, or the unchanged value of c if c is
already uppercase, has no uppercase equivalent, or is not alphabetic.
例如,在“6”上调用 ToUpper
将 return“6”,因为数字没有大写。
MSDN 示例显示了几种不同转换的结果:
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)
// ? --> ?
// ä --> Ä
char.ToUpper
的文档指出:
Return Value
Type: System.Char
The uppercase equivalent of c, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.
转换 to/from 驼峰式大小写的编写方法 我有一个想法 - 如果有人使用没有大写形式的 Unicode 字符出现并通过我的函数运行它怎么办?如果有人将已经大写的 'A'
传递给 Char.ToUpper
怎么办?我检查了参考源,它只是引导到一个 DllImport - 我知道核心 CLR 源是可用的,但我不是很擅长导航它(我认为它组织得不好,但也许我只是不明白逻辑).
当你将这些东西传递给那个函数时会发生什么?我知道我可以测试它,但是有没有像这样的情况发生故障?任何抛出异常或导致任何类型的失败或意外行为的东西?我希望该函数在任何情况下都将 return 原始字符转换为大写字母无效,但情况是这样吗?
这记录在 Char.ToUpper method documentation on MSDN 中 return 值下的方法:
The uppercase equivalent of c, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.
所以它不会中断,它只是return你调用方法的字符,不变。
根据MSDN它returns:
The uppercase equivalent of c, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.
例如,在“6”上调用 ToUpper
将 return“6”,因为数字没有大写。
MSDN 示例显示了几种不同转换的结果:
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)
// ? --> ?
// ä --> Ä
char.ToUpper
的文档指出:
Return Value
Type: System.Char
The uppercase equivalent of c, or the unchanged value of c if c is already uppercase, has no uppercase equivalent, or is not alphabetic.