Last active
August 4, 2016 14:48
-
-
Save NiKoTron/eca8c7449fbcfdefb324e85a34404532 to your computer and use it in GitHub Desktop.
get all entries in string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static List<int> AllIndexesOf (this string str, string value) | |
{ | |
if (System.String.IsNullOrEmpty (value)) | |
throw new ArgumentException ("строка не может быть пустой", "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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment