.NET, Code

Delimited String to Generic List<>

This is something that I tend to forget even though it’s pretty basic and probably obvious to most.  I have a comma delimited string which I wanted to put into a List<>. Here’s a one-liner to get the job done.

List aList = new List();
aList.AddRange(myString.Split(','));

Where myString is my comma-delimited string.  Pretty basic, but very handy.

Advertisements