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();
            }

posted on 2010-04-07 21:33  WPF之家  阅读(288)  评论(0编辑  收藏  举报