Linq

Voici une petite astuce pour convertir un tableau de string en int trié par ordre croissant via Linq et les expressions lambda.

string[] numbers = {"0010", "5", "12", "003"};
int[] nums = numbers.Select(s => Int32.Parse(s)).OrderBy(s => s).ToArray();

En parcourant le tableau de int on devrait obtenir le résultat suivant:
3
5
10
12

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Add comment


(Will show your Gravatar icon)  

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

August 28. 2008 19:02