I'm trying to create substrings from each index in a string using this helper method
public List<int> AllIndexesOf(string str, string value)
{
if (String.IsNullOrEmpty(value))
throw new ArgumentException("the string to find may 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);
}
}
And the way I am using it is like this
string input = "27758585926302004842";
List<int> eh = AllIndexesOf(input, "2");
So I essentially want to grab each string between the indexes in two.
So the subscring between index 0 and 9 and 13 and 19.
I'm just not sure how to do this without using linq