BF2Statistics.StringExtensions.IndexesOf C# (CSharp) Method

IndexesOf() public static method

Returns all the index's of the given string input
public static IndexesOf ( this str, string value ) : List
str this
value string
return List
        public static List<int> IndexesOf(this string str, string value)
        {
            if (String.IsNullOrEmpty(value))
                throw new ArgumentException("The search string must not be empty", "value");

            List<int> indexes = new List<int>();
            for (int index = 0; ; index += value.Length)
            {
                index = str.IndexOf(value, index);
                if (index == -1)
                    return indexes;
                indexes.Add(index);
            }
        }