Alarm.ExtentionMethods.IndexesOf C# (CSharp) 메소드

IndexesOf() 공개 정적인 메소드

public static IndexesOf ( this haystack, string needle ) : IEnumerable
haystack this
needle string
리턴 IEnumerable
        public static IEnumerable<int> IndexesOf(this string haystack, string needle)
        {
            int lastIndex = 0;
            while (true) {
                int index = haystack.IndexOf(needle, lastIndex);
                if (index == -1) {
                    yield break;
                }
                yield return index;
                lastIndex = index + needle.Length;
            }
        }