学用 ASP.Net 之 System.Char 结构
成员:
/* 常数字段 */MaxValue //65535MinValue //0/* 静态方法 */Char.ConvertFromUtf32() //转 Unicode 值到字符串Char.ConvertToUtf32() //转到 Unicode 值Char.Equals() //=Char.GetNumericValue() //数字字符转换成相应的值, 返回类型是 DoubleChar.GetUnicodeCategory() //获取字符类别Char.IsControl() //?控制字符Char.IsDigit() //?十进制数字(0..9)Char.IsHighSurrogate() //?高代理项码位(U+D800...U+DBFF)Char.IsLetter() //?字母Char.IsLetterOrDigit() //?字母或十进制数字?Char.IsLower() //?小写字母(a..z 等)Char.IsLowSurrogate() //?低代理项码位(U+DC00...U+DFFF)Char.IsNumber() //?数字(0..9 等)Char.IsPunctuation() //?标点符号?Char.IsSeparator() //?分隔符(空格等)Char.IsSurrogate() //?代理项码位Char.IsSurrogatePair() //判断两个 Char 对象是否形成代理项对Char.IsSymbol() //?符号($ + = < > ^ ` | 等)Char.IsUpper() //?大写字母(A..Z 等)Char.IsWhiteSpace() //?空白Char.Parse() //转换单字符的 String 到 CharChar.ToLower() //转小写Char.ToLowerInvariant() //转小写, 使用区域性规则Char.ToString() //Char.ToUpper() //转大写Char.ToUpperInvariant() //转大写, 使用区域性规则Char.TryParse() //尝试转换单字符的 String 到 Char/* 对象方法 */CompareTo() //对比, 返回表示距离的整数
GetNumericValue():
protected void Button1_Click(object sender, EventArgs e){ double f1 = char.GetNumericValue('9'); // 9 double f2 = char.GetNumericValue('A'); //-1 double f3 = char.GetNumericValue('万'); //-1 double f4 = char.GetNumericValue("A1B2", 3); // 2 TextBox1.Text = string.Concat(f1, "\n", f2, "\n", f3, "\n", f4);}
ConvertFromUtf32()、ConvertToUtf32():
protected void Button1_Click(object sender, EventArgs e){ string s1 = char.ConvertFromUtf32(65); //A string s2 = char.ConvertFromUtf32(0x4e07); //万 int n1 = char.ConvertToUtf32("ABC", 1); //66 int n2 = char.ConvertToUtf32("万", 0); //19975 TextBox1.Text = string.Concat(s1, "\n", s2, "\n", n1, "\n", n2);}
GetUnicodeCategory():
protected void Button1_Click(object sender, EventArgs e){ char c; string str = ""; for (int i = 20; i < 256; i++) { c = Convert.ToChar(i); str += string.Format("{0}\t{1}\t{2}\n", i, c, char.GetUnicodeCategory(c)); } TextBox1.Text = str;}/* 测试结果:20Control21Control22Control23Control24Control25Control26Control27Control28Control29Control30Control31Control32 SpaceSeparator33!OtherPunctuation34"OtherPunctuation35#OtherPunctuation36$CurrencySymbol37%OtherPunctuation38&OtherPunctuation39'OtherPunctuation40(OpenPunctuation41)ClosePunctuation42*OtherPunctuation43+MathSymbol44,OtherPunctuation45-DashPunctuation46.OtherPunctuation47/OtherPunctuation480DecimalDigitNumber491DecimalDigitNumber502DecimalDigitNumber513DecimalDigitNumber524DecimalDigitNumber535DecimalDigitNumber546DecimalDigitNumber557DecimalDigitNumber568DecimalDigitNumber579DecimalDigitNumber58:OtherPunctuation59;OtherPunctuation60<MathSymbol61=MathSymbol62>MathSymbol63?OtherPunctuation64@OtherPunctuation65AUppercaseLetter66BUppercaseLetter67CUppercaseLetter68DUppercaseLetter69EUppercaseLetter70FUppercaseLetter71GUppercaseLetter72HUppercaseLetter73IUppercaseLetter74JUppercaseLetter75KUppercaseLetter76LUppercaseLetter77MUppercaseLetter78NUppercaseLetter79OUppercaseLetter80PUppercaseLetter81QUppercaseLetter82RUppercaseLetter83SUppercaseLetter84TUppercaseLetter85UUppercaseLetter86VUppercaseLetter87WUppercaseLetter88XUppercaseLetter89YUppercaseLetter90ZUppercaseLetter91[OpenPunctuation92\OtherPunctuation93]ClosePunctuation94^ModifierSymbol95_ConnectorPunctuation96`ModifierSymbol97aLowercaseLetter98bLowercaseLetter99cLowercaseLetter100dLowercaseLetter101eLowercaseLetter102fLowercaseLetter103gLowercaseLetter104hLowercaseLetter105iLowercaseLetter106jLowercaseLetter107kLowercaseLetter108lLowercaseLetter109mLowercaseLetter110nLowercaseLetter111oLowercaseLetter112pLowercaseLetter113qLowercaseLetter114rLowercaseLetter115sLowercaseLetter116tLowercaseLetter117uLowercaseLetter118vLowercaseLetter119wLowercaseLetter120xLowercaseLetter121yLowercaseLetter122zLowercaseLetter123{OpenPunctuation124|MathSymbol125}ClosePunctuation126~MathSymbol127Control128Control129Control130Control131Control132Control133 Control134Control135Control136Control137Control138Control139Control140Control141Control142Control143Control144Control145Control146Control147Control148Control149Control150Control151Control152Control153Control154Control155Control156Control157Control158Control159Control160 SpaceSeparator161¡OtherPunctuation162¢CurrencySymbol163£CurrencySymbol164¤CurrencySymbol165¥CurrencySymbol166¦OtherSymbol167§OtherSymbol168¨ModifierSymbol169©OtherSymbol170ªLowercaseLetter171«InitialQuotePunctuation172¬MathSymbol173DashPunctuation174®OtherSymbol175¯ModifierSymbol176°OtherSymbol177±MathSymbol178²OtherNumber179³OtherNumber180´ModifierSymbol181µLowercaseLetter182¶OtherSymbol183·OtherPunctuation184¸ModifierSymbol185¹OtherNumber186ºLowercaseLetter187»FinalQuotePunctuation188¼OtherNumber189½OtherNumber190¾OtherNumber191¿OtherPunctuation192ÀUppercaseLetter193ÁUppercaseLetter194ÂUppercaseLetter195ÃUppercaseLetter196ÄUppercaseLetter197ÅUppercaseLetter198ÆUppercaseLetter199ÇUppercaseLetter200ÈUppercaseLetter201ÉUppercaseLetter202ÊUppercaseLetter203ËUppercaseLetter204ÌUppercaseLetter205ÍUppercaseLetter206ÎUppercaseLetter207ÏUppercaseLetter208ÐUppercaseLetter209ÑUppercaseLetter210ÒUppercaseLetter211ÓUppercaseLetter212ÔUppercaseLetter213ÕUppercaseLetter214ÖUppercaseLetter215×MathSymbol216ØUppercaseLetter217ÙUppercaseLetter218ÚUppercaseLetter219ÛUppercaseLetter220ÜUppercaseLetter221ÝUppercaseLetter222ÞUppercaseLetter223ßLowercaseLetter224àLowercaseLetter225áLowercaseLetter226âLowercaseLetter227ãLowercaseLetter228äLowercaseLetter229åLowercaseLetter230æLowercaseLetter231çLowercaseLetter232èLowercaseLetter233éLowercaseLetter234êLowercaseLetter235ëLowercaseLetter236ìLowercaseLetter237íLowercaseLetter238îLowercaseLetter239ïLowercaseLetter240ðLowercaseLetter241ñLowercaseLetter242òLowercaseLetter243óLowercaseLetter244ôLowercaseLetter245õLowercaseLetter246öLowercaseLetter247÷MathSymbol248øLowercaseLetter249ùLowercaseLetter250úLowercaseLetter251ûLowercaseLetter252üLowercaseLetter253ýLowercaseLetter254þLowercaseLetter255ÿLowercaseLetter*/