You can use LINQ
after Split
:
string str = "The, quick brown, fox";
string[] splitsWithTrim = str.Split(',').Select(x => x.Trim()).ToArray();
Or you can change your seperator to ", "
(comma + space).It is also work for this case because there is only one white-space
after each comma
:
string[] splitsWithTrim = str.Split(new[] { ", " }, StringSplitOptions.None);