C#判断单词个数

版权声明:转载原创文章请以超链接形式请注明原文章出处,尊重作者,尊重原创!


恰饭广告




判断英文单词个数:

using System;
namespace FindWord
{
    class Program
    {
        static void Main(string[] args)
        {
            string space = " ";
            string str = "hello world" + space;
            int count = 0;
            bool start = false;
            for (int i=0;i<str.Length;i++)
            {
                if (Char .IsLetter(str[i]))
                {
                    start = true;
                }
                if (!Char.IsLetter(str[i])&&start)
                {
                    count++;
                    start = false;
                }
            }
            Console.WriteLine(count);
            Console.ReadLine();
        }
    }
}

原文链接:https://www.idaobin.com/archives/962.html

让我恰个饭吧.ヘ( ̄ω ̄ヘ)

支付宝 ——————- 微信
图片加载中图片加载中



恰饭广告

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

24 ÷ 8 =