using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace CRApp
{
    static class Program
    {
        static int Main(string[] args)
        {
            const string text = "意思:阿呆给乔局长送红包时,两人的对话颇有意思。 乔局长:“你这是什么意思?”
阿呆:“没什么,意思意思。” 乔局长:“你这就不够意思了。” 阿呆:“小意思,小意思。” 乔局长:“你这人真有意思。” 阿呆:“其实也没有别的意思。”
乔局长:“那我就不好意思了。” 阿呆:“是我不好意思。”";
            IEnumerable<int> indexList = FindIndex(text,"意思");
            foreach (var item in indexList)
            {
                Console.WriteLine(item);
            }
            return (0);
        }

public static IEnumerable<int> FindIndex (string text,string word)
        {
            if (text.Length<1||word.Length<1)
            {
                yield break;
            }
            int index = 0 - word.Length;
            while ((index = text.IndexOf(word, index + word.Length)) > -1)
            {
                yield return (index);
            }
                yield break;
        }
    }
}
 

技术
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信