Reputation: 2991
What is the best way to convert a List of primitive longs to an array of strings?
I think I'm looking for something fancier than writing my own loop, etc..
Upvotes: 4
Views: 2354
Reputation: 99999
This is worth checking against the performance of a select statement.
string[] result = Array.ConvertAll(list.ToArray(), i => i.ToString());
Upvotes: 2
Reputation: 96557
This should do the trick:
string[] arr = list.Select(l => l.ToString()).ToArray();
Upvotes: 16