随笔 - 2146  文章 - 19 评论 - 11846 阅读 - 1267万


成员:
/* 字段 */
MaxValue //65535
MinValue //0

/* 静态方法 */
Char.ConvertFromUtf32()   //转 Unicode 值到字符串
Char.ConvertToUtf32()     //转到 Unicode 值
Char.Equals()             //=
Char.GetNumericValue()    //数字字符转换成相应的值, 返回类型是 Double
Char.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 到 Char
Char.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;
}

/* 测试结果:
20		Control
21		Control
22		Control
23		Control
24		Control
25		Control
26		Control
27		Control
28		Control
29		Control
30		Control
31		Control
32	 	SpaceSeparator
33	!	OtherPunctuation
34	"	OtherPunctuation
35	#	OtherPunctuation
36	$	CurrencySymbol
37	%	OtherPunctuation
38	&	OtherPunctuation
39	'	OtherPunctuation
40	(	OpenPunctuation
41	)	ClosePunctuation
42	*	OtherPunctuation
43	+	MathSymbol
44	,	OtherPunctuation
45	-	DashPunctuation
46	.	OtherPunctuation
47	/	OtherPunctuation
48	0	DecimalDigitNumber
49	1	DecimalDigitNumber
50	2	DecimalDigitNumber
51	3	DecimalDigitNumber
52	4	DecimalDigitNumber
53	5	DecimalDigitNumber
54	6	DecimalDigitNumber
55	7	DecimalDigitNumber
56	8	DecimalDigitNumber
57	9	DecimalDigitNumber
58	:	OtherPunctuation
59	;	OtherPunctuation
60	<	MathSymbol
61	=	MathSymbol
62	>	MathSymbol
63	?	OtherPunctuation
64	@	OtherPunctuation
65	A	UppercaseLetter
66	B	UppercaseLetter
67	C	UppercaseLetter
68	D	UppercaseLetter
69	E	UppercaseLetter
70	F	UppercaseLetter
71	G	UppercaseLetter
72	H	UppercaseLetter
73	I	UppercaseLetter
74	J	UppercaseLetter
75	K	UppercaseLetter
76	L	UppercaseLetter
77	M	UppercaseLetter
78	N	UppercaseLetter
79	O	UppercaseLetter
80	P	UppercaseLetter
81	Q	UppercaseLetter
82	R	UppercaseLetter
83	S	UppercaseLetter
84	T	UppercaseLetter
85	U	UppercaseLetter
86	V	UppercaseLetter
87	W	UppercaseLetter
88	X	UppercaseLetter
89	Y	UppercaseLetter
90	Z	UppercaseLetter
91	[	OpenPunctuation
92	\	OtherPunctuation
93	]	ClosePunctuation
94	^	ModifierSymbol
95	_	ConnectorPunctuation
96	`	ModifierSymbol
97	a	LowercaseLetter
98	b	LowercaseLetter
99	c	LowercaseLetter
100	d	LowercaseLetter
101	e	LowercaseLetter
102	f	LowercaseLetter
103	g	LowercaseLetter
104	h	LowercaseLetter
105	i	LowercaseLetter
106	j	LowercaseLetter
107	k	LowercaseLetter
108	l	LowercaseLetter
109	m	LowercaseLetter
110	n	LowercaseLetter
111	o	LowercaseLetter
112	p	LowercaseLetter
113	q	LowercaseLetter
114	r	LowercaseLetter
115	s	LowercaseLetter
116	t	LowercaseLetter
117	u	LowercaseLetter
118	v	LowercaseLetter
119	w	LowercaseLetter
120	x	LowercaseLetter
121	y	LowercaseLetter
122	z	LowercaseLetter
123	{	OpenPunctuation
124	|	MathSymbol
125	}	ClosePunctuation
126	~	MathSymbol
127		Control
128	€	Control
129		Control
130	‚	Control
131	ƒ	Control
132	„	Control
133	…	Control
134	†	Control
135	‡	Control
136	ˆ	Control
137	‰	Control
138	Š	Control
139	‹	Control
140	Œ	Control
141		Control
142	Ž	Control
143		Control
144		Control
145	‘	Control
146	’	Control
147	“	Control
148	”	Control
149	•	Control
150	–	Control
151	—	Control
152	˜	Control
153	™	Control
154	š	Control
155	›	Control
156	œ	Control
157		Control
158	ž	Control
159	Ÿ	Control
160	 	SpaceSeparator
161	¡	OtherPunctuation
162	¢	CurrencySymbol
163	£	CurrencySymbol
164	¤	CurrencySymbol
165	¥	CurrencySymbol
166	¦	OtherSymbol
167	§	OtherSymbol
168	¨	ModifierSymbol
169	©	OtherSymbol
170	ª	LowercaseLetter
171	«	InitialQuotePunctuation
172	¬	MathSymbol
173	­	DashPunctuation
174	®	OtherSymbol
175	¯	ModifierSymbol
176	°	OtherSymbol
177	±	MathSymbol
178	²	OtherNumber
179	³	OtherNumber
180	´	ModifierSymbol
181	µ	LowercaseLetter
182	¶	OtherSymbol
183	·	OtherPunctuation
184	¸	ModifierSymbol
185	¹	OtherNumber
186	º	LowercaseLetter
187	»	FinalQuotePunctuation
188	¼	OtherNumber
189	½	OtherNumber
190	¾	OtherNumber
191	¿	OtherPunctuation
192	À	UppercaseLetter
193	Á	UppercaseLetter
194	Â	UppercaseLetter
195	Ã	UppercaseLetter
196	Ä	UppercaseLetter
197	Å	UppercaseLetter
198	Æ	UppercaseLetter
199	Ç	UppercaseLetter
200	È	UppercaseLetter
201	É	UppercaseLetter
202	Ê	UppercaseLetter
203	Ë	UppercaseLetter
204	Ì	UppercaseLetter
205	Í	UppercaseLetter
206	Î	UppercaseLetter
207	Ï	UppercaseLetter
208	Ð	UppercaseLetter
209	Ñ	UppercaseLetter
210	Ò	UppercaseLetter
211	Ó	UppercaseLetter
212	Ô	UppercaseLetter
213	Õ	UppercaseLetter
214	Ö	UppercaseLetter
215	×	MathSymbol
216	Ø	UppercaseLetter
217	Ù	UppercaseLetter
218	Ú	UppercaseLetter
219	Û	UppercaseLetter
220	Ü	UppercaseLetter
221	Ý	UppercaseLetter
222	Þ	UppercaseLetter
223	ß	LowercaseLetter
224	à	LowercaseLetter
225	á	LowercaseLetter
226	â	LowercaseLetter
227	ã	LowercaseLetter
228	ä	LowercaseLetter
229	å	LowercaseLetter
230	æ	LowercaseLetter
231	ç	LowercaseLetter
232	è	LowercaseLetter
233	é	LowercaseLetter
234	ê	LowercaseLetter
235	ë	LowercaseLetter
236	ì	LowercaseLetter
237	í	LowercaseLetter
238	î	LowercaseLetter
239	ï	LowercaseLetter
240	ð	LowercaseLetter
241	ñ	LowercaseLetter
242	ò	LowercaseLetter
243	ó	LowercaseLetter
244	ô	LowercaseLetter
245	õ	LowercaseLetter
246	ö	LowercaseLetter
247	÷	MathSymbol
248	ø	LowercaseLetter
249	ù	LowercaseLetter
250	ú	LowercaseLetter
251	û	LowercaseLetter
252	ü	LowercaseLetter
253	ý	LowercaseLetter
254	þ	LowercaseLetter
255	ÿ	LowercaseLetter
*/

posted on   万一  阅读(1713)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
历史上的今天:
2009-01-02 C# 语法练习(12): 类[四] - 抽象类与抽象成员、密封类与密封成员
2009-01-02 C# 语法练习(11): 类[三] - 构造函数、析构函数、base、this
2009-01-02 C# 语法练习(10): 类[二] - 继承、覆盖、多态、隐藏
2009-01-02 C# 语法练习(9): 类[一] - 访问限制、方法、字段、属性
2008-01-02 Delphi 中的 XMLDocument 类详解(1) - 等待研究的内容
2008-01-02 xml 语法提示
2008-01-02 关于 Delphi 中流的使用(9) 分割与合并文件的函数


点击右上角即可分享
微信分享提示