WinForm 字符串判断是否为字母? [VS2005 WinForm C#]string str="A";if(如何判断str是否为字母?){//是字母}else{//不是} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 char str='A';if(char.IsLetter('A')){//是字母}else{//不是} 判断他的ASCII码65-90 == A-Z97-122 == a-z public static boolean IsEnglishCharacter(String strin) { char c; for( int i=0 ; i<strin.length() ; i++ ){ c = strin.charAt (i); if (( c <= 0x007A && c >= 0x0061 ) == false && ( c <= 0x005A && c >= 0x0041 ) == false ) return false; } return true; } if(IsEnglishCharacter==true){}else{} char.IsLetter判断是否为字母 string str 的值来自文本框如何把string 转换为char ? 正則表達式匹配字符串: ^[a-zA-Z]+$匹配單一字符: ^[a-zA-Z]$ string str = "asdfasdfdfghsdfg"; char[] cs = str.ToCharArray(); private void button1_Click(object sender, EventArgs e) { char c = textBox2.Text[0];//textBox2.tex="我们"; if (char.IsLetter(c)) { MessageBox.Show("yes");//汉字 也被判断为字母了,我是不是什么地方写错了? } } private void button1_Click(object sender, EventArgs e) { char c = textBox2.Text[0];//textBox2.tex="我们"; if (c >= 'A' && c <= 'Z' || c >= 'a' || c <= 'z') { MessageBox.Show("yes"); } }// 汉字在 Unicode 也被认为是字母的。 上面错了,更正一下:if (c >= 'A' && c <= 'Z' || c >= 'a' || c <= 'z')改为:if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') 使用11楼wuyi8808的方法解决 private void button1_Click(object sender, EventArgs e) { char c = textBox2.Text[0]; if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z') { MessageBox.Show("yes"); } else { MessageBox.Show("no"); } } C# WinWordControl控件支持office07 base.innerlist xbox模拟登录 怎么组合这串数字并计算它的组合总数? 谁能帮我! sql函数怎么用C#实现? 请继承DockContent的form表单如何排序 高分求Longhorn 4074 SDK? GDI+打印 页面设置的问题? 求助 求教:如何在遍历HashTable时修改Values值? 求救VB和C#都通的高手!!!(FOR循环转不过来,则样在C#中实现object型变量进行for循环) 请推荐一个带socket重连的c#程序
if(char.IsLetter('A'))
{
//是字母
}
else
{
//不是
}
65-90 == A-Z
97-122 == a-z
{
char c;
for( int i=0 ; i<strin.length() ; i++ ){
c = strin.charAt (i);
if (( c <= 0x007A && c >= 0x0061 ) == false &&
( c <= 0x005A && c >= 0x0041 ) == false )
return false;
}
return true; }
if(IsEnglishCharacter==true)
{}else{}
判断是否为字母
如何把string 转换为char ?
匹配字符串: ^[a-zA-Z]+$
匹配單一字符: ^[a-zA-Z]$
char[] cs = str.ToCharArray();
{
char c = textBox2.Text[0];//textBox2.tex="我们";
if (char.IsLetter(c))
{
MessageBox.Show("yes");//汉字 也被判断为字母了,我是不是什么地方写错了?
}
}
{
char c = textBox2.Text[0];//textBox2.tex="我们";
if (c >= 'A' && c <= 'Z' || c >= 'a' || c <= 'z')
{
MessageBox.Show("yes");
}
}
// 汉字在 Unicode 也被认为是字母的。
private void button1_Click(object sender, EventArgs e)
{
char c = textBox2.Text[0];
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'z')
{
MessageBox.Show("yes");
}
else
{
MessageBox.Show("no");
}
}