阅读背景:

在字符串里寻找某字符出现的个数

来源:互联网 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 字符串1
{
    class Program
    {
        static void Main(string[] args) 
        {
            int n = 0; 

            Console.WriteLine("请输入字符串:"); 

            string B = Console.ReadLine();     

            B = B.ToLower();   
              
            if (B.IndexOf("b") < 0)       
            {
                Console.WriteLine("您输入的字符串里不包含字母b");

            }
            else
            {

                int c = B.Length;

                for ( n = 0; n <= c; n++)
                {
                    int b = B.IndexOf("b");
                    if (b < 0)
                                          
                        break;             
       
                    B = B.Substring(b+1);

                } Console.WriteLine("字符串中含b有" +n+"个");
                
            }Console.ReadLine();
            

        }
    }
}
using System;
using System.Collections.Gene



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: