Reputation: 113
Lambda expression to convert list int to list string
List<int> lstNum = new List<int>(new int[] { 3, 6, 7, 9 });
Upvotes: 9
Views: 6559
Reputation: 22876
No need for lambda:
var lstNum = new [] { 3, 6, 7, 9 }.ToList();
var lstStr = lstNum.ConvertAll(Convert.ToString);
Upvotes: 3
Reputation: 9151
This will work as well:
List<string> lstString = lstNum.Select(x => x.ToString()).ToList();
Upvotes: 3
Reputation: 12393
You can use the following to convert a List of int to a List of string:
List<string> lstStr = lstNum.ConvertAll<string>(x => x.ToString());
Upvotes: 13