Created
October 11, 2013 19:14
-
-
Save DTTerastar/6940423 to your computer and use it in GitHub Desktop.
Split and trim a string. Does not return empty strings.
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 IEnumerable<string> SplitTrim(this string input, params char[] separator) | |
{ | |
if (input == null) throw new ArgumentNullException("input"); | |
string[] strings = input.Trim().Split(separator); | |
foreach (var s in strings) | |
{ | |
string trimmed = s.Trim(); | |
if (!String.IsNullOrWhiteSpace(trimmed)) | |
yield return trimmed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment