Search code examples
c#stringsplit

C# Split up words with two colons


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.


Solution

  • 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, "::");