

using System;
using System.Linq;
namespace caCop
{
class Program
{
static void Main(string[] args)
{
Ogrenci[] arrOgrenci = new Ogrenci[5];
arrOgrenci[0] = new Ogrenci() { adi = "ali", yas = 30 };
arrOgrenci[1] = new Ogrenci() { adi = "veli", yas = 30 };
arrOgrenci[2] = new Ogrenci() { adi = "mehmet", yas = 33 };
arrOgrenci[3] = new Ogrenci() { adi = "selim", yas = 33 };
arrOgrenci[4] = new Ogrenci() { adi = "yakup", yas = 33 };
foreach (Ogrenci ogrenci in arrOgrenci)
{
Console.WriteLine(ogrenci);
}
Console.WriteLine("-----");
Lookup lookup = (Lookup) (arrOgrenci.ToLookup(ob => ob.yas));
foreach (Ogrenci ogrenci in lookup[30])
{
Console.WriteLine(ogrenci);
}
}
}
class Ogrenci
{
public int yas { get; set; }
public string adi { get; set; }
public override string ToString()
{
return adi + " \t-> " + yas;
}
}
}
Hiç yorum yok:
Yorum Gönder