1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace test_LINQMyBook
{
class Program
{
static void Main(string[] args)
{
List<Pers> lPers = new List<Pers>
{
new Pers {Nom="Joe", Age=30}, new Pers {Nom="Arnaud",Age=26}, new Pers {Nom="Hans",Age=85}, new Pers {Nom="Arthur",Age=4}
};
var personnes = from p in lPers select p.Nom; // ou var personnes = lPers.Select (p =>p.Nom);
foreach (string s in personnes)
{ Console.WriteLine(s); Console.ReadLine(); }
}
}
} |