views:

110

answers:

2

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..

+7  A: 

This should do the trick:

string[] arr = list.Select(l => l.ToString()).ToArray();
Ahmad Mageed
+1 I'm too slow.
womp
@womp: thanks :)
Ahmad Mageed
+2  A: 

This is worth checking against the performance of a select statement.

string[] result = Array.ConvertAll(list.ToArray(), i => i.ToString());
280Z28
+1 for the fun suggestion. :)
Chris Dwyer