您的位置:首页 > 其它

如何获得一个字符串中数字的长度

2010-04-07 21:33 387 查看
ArrayList itemList = new ArrayList();
CharEnumerator CEnumerator = textBox1.Text.GetEnumerator();
while (CEnumerator.MoveNext())
{
byte[] array = new byte[1];
array = System.Text.Encoding.ASCII.GetBytes(CEnumerator.Current.ToString());
int asciicode = (short)(array[0]);
if (asciicode >= 48 && asciicode <= 57)
{
itemList.Add(CEnumerator.Current.ToString());
}
textBox2.Text = itemList.Count.ToString();
}

ArrayList itemList = new ArrayList();
CharEnumerator CEnumerator = textBox1.Text.GetEnumerator();
while (CEnumerator.MoveNext())
{
byte[] array = new byte[1];
array = System.Text.Encoding.ASCII.GetBytes(CEnumerator.Current.ToString());
int asciicode = (short)(array[0]);
if ((asciicode >= 48 && asciicode <= 57) || (asciicode >= 65 && asciicode <= 90) || (asciicode >= 97 && asciicode <= 122))
{
itemList.Add(CEnumerator.Current.ToString());
}
textBox2.Text = itemList.Count.ToString();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐