获取字符的ASCII 码
获取一个字符的(char类型)的ASCII 码用什么函数?需要什么命名空间? 问题点数:20、回复次数:4Top
1 楼HAVENT(夜雨流星℡)回复于 2006-03-16 09:00:17 得分 10
ASC() Chr()
用这两个函数就能实现互相转换了,这个是VB基类里面的,不用继承,直接用Top
2 楼chenxi6713(番茄)回复于 2006-03-16 09:02:03 得分 0
你先搜索下,csdn里面有很多的。
下面是别人的代码帖过来的。
private void TestChar() {
char ch = ''a''; short ii = 65;
this.textBox1.Text = "";
this.textBox1.AppendText("The ASCII code of \''" + ch + "\'' is: " + (short) ch + "\n");
this.textBox1.AppendText("ASCII is " + ii.ToString() + ", the char is: " + (char) ii + "\n");
char cn = ''中''; short uc = 22478;
this.textBox1.AppendText("The Unicode of \''" + cn + "\'' is: " + (short) cn + "\n");
this.textBox1.AppendText("Unicode is " + uc.ToString() + ", the char is: " + (char) uc + "\n");
}
它的运行结果是
The ASCII code of ''a'' is: 97
ASCII is 65, the char is: A
The Unicode of ''中'' is: 20013
Unicode is 22478, the char is: 城
Top
3 楼43720938(烦烦烦烦)回复于 2006-03-16 09:16:15 得分 10
VB.NET里直接可以用
Asc(你的字符)Top
4 楼truecoffeefox(咖啡狐)回复于 2006-03-16 09:20:02 得分 0
其实供能是这样的,我读一段string,里边有空格和换行也许是回车换行,我想用程序控制把它们去掉,是不是可以用一个循环,读取其中的每个字符(char)然后判断它是不是空格之类的,在进行连接或者丢弃这样的操作。这样好像有点笨,也听消耗资源的,string挺长的,有什么更好的办法吗?Top




