.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

One thought on “Delimited String to Generic List<>

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s