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


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

    作者:观海看云个人开发历程知识库 - 博客园
    出处:http://www.cnblogs.com/zhangtao/
    文章版权归本人所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    设计模式之-装饰模式
    设计模式之-组合模式
    设计模式之-桥接模式
    设计模式之-适配器模式
    Java import static 静态导入
    C语言:字符数组 + 字符串指针
    leetcode 435.无重叠区间
    C++:强制类型转换
    C++:移动构造函数和移动赋值运算符
    编程:找出所有符合条件的元素
  • 原文地址:https://www.cnblogs.com/zhangtao/p/1706726.html
Copyright © 2020-2023  润新知