I have a incoming string looking like this: xxxx::xxxxx::xxxxxx
How can I split the string after every '::'? I can get it to do with just one colon, but not two.
Try this:
var splitted =
yourString.Split(new []{"::"},StringSplitOptions.RemoveEmptyEntries);
You can split only on string[]
not on string
EDIT:
as Adil said you can always use Regex.Split
var splitted = Regex.Split(yourString, "::");
Or you could use this code snippet :
List<string> resList = new List<string>();
int fIndx = 0;
for (int i = 0; i < a.Length; i++)
{
if(a[i] == ':' && a[i+1] == ':')
{
resList.Add(a.Substring(fIndx, i - fIndx));
fIndx = i + 2;
}
}