zoukankan      html  css  js  c++  java
  • 如何获得一个字符串中数字的长度

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

    作者:wpf之家
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    渗透测试工具sqlmap基础教程
    安全测试——利用Burpsuite密码爆破(Intruder入侵)
    什么是AWVS
    渗透测试工具sqlmap基础教程
    安全测试——利用Burpsuite密码爆破(Intruder入侵)
    AWVS基本用法
    scrapy爬虫框架教程(二)-- 爬取豆瓣电影
    全链路压测平台在美团中的实践
    全链路压测平台在美团中的实践
    bzoj 1934: [Shoi2007]Vote 善意的投票
  • 原文地址:https://www.cnblogs.com/wpf123/p/2347345.html
Copyright © 2011-2022 走看看