亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C#統(tǒng)計(jì)字符串中數(shù)字個(gè)數(shù)的方法

 更新時(shí)間:2015年06月26日 17:53:54   作者:pythoner  
這篇文章主要介紹了C#統(tǒng)計(jì)字符串中數(shù)字個(gè)數(shù)的方法,涉及C#遍歷字符串并判斷數(shù)字的技巧,需要的朋友可以參考下

本文實(shí)例講述了C#統(tǒng)計(jì)字符串中數(shù)字個(gè)數(shù)的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

// DigitCounter.cs
// 編譯時(shí)使用:/target:library
using System; 
// 聲明與 Factorial.cs 中的命名空間相同的命名空間。這樣僅允許將 
// 類型添加到同一個(gè)命名空間中。
namespace Functions 
{
 public class DigitCount 
 {
  // NumberOfDigits 靜態(tài)方法計(jì)算
  // 傳遞的字符串中數(shù)字字符的數(shù)目:
  public static int NumberOfDigits(string theString) 
  {
   int count = 0; 
   for ( int i = 0; i < theString.Length; i++ ) 
   {
    if ( Char.IsDigit(theString[i]) ) 
    {
     count++; 
    }
   }
   return count;
  }
 }
}

希望本文所述對(duì)大家的C#程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論