Comma separated strings to distinct list conversion in C#

Today we are going to see that how to convert comma separated string to list conversion . I hope we may come across this kind to situation. So it will be more helpful .

string commaSeparatedString ="1,2,3,4,5,,6";

List<string> lstDistinctString = new List<string>();

lstDistinctString = commaSeparatedString.Trim().Split(',').Where(s =>           !string.IsNullOrWhiteSpace(s)).Distinct().ToList();


Output:
1
2
3
4
5
6

Comments

Popular posts from this blog

Types of Architects

Basic measurements

Search html table contents based on its td using Jquery