Convert List<int> to List<string> in C#

I was faced with a micro challenge, of converting a List<int> to List<string>. After struggling for some time, decided to Google and found the the following solution !

List intList = new List();
List stringList = new List();

for (int i = 0; i < 10; i++)
	intList.Add(i);

stringList = intList.ConvertAll(delegate(int i) { return i.ToString(); });

Source: http://stackoverflow.com/questions/44942/cast-listint-to-liststring-in-net-2-0


Leave a Reply

Your email address will not be published / Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.