Oğuz Yağmur'un Günlüğü
Net Bi'log (Tecrübe, ilimden üstündür. İbn-i Sina)
Navigation for Oğuz Yağmur'un Günlüğü - Nesneleri Property'sine Göre Sıralamak
Content
Sidebar
Footer
May 14, 2007
@ 11:38 PM
Comments [5]
Nesneleri Property'sine Göre Sıralamak
.Net Akademi eğitiminden bir ders çalışması...
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Collections;
namespace sortedbyProperty
{
class Program
{
static void Main(string[] args)
{
HedeColl h = new HedeColl();
h.Add(new Ogrenci(2, "ali", DateTime.Now.AddDays(10)));
h.Add(new Ogrenci(21, "ahmet", DateTime.Now.AddDays(1)));
h.Add(new Ogrenci(12, "mehmet", DateTime.Now.AddDays(122)));
h.Sortla("Tarih",BuyukKucuk.Buyuk);
foreach (Ogrenci o in h)
{
Console.WriteLine(o);
}
}
}
enum BuyukKucuk
{
Buyuk,
Kucuk
}
class HedeColl : List<Ogrenci>
{
public HedeColl()
{
}
public void Sortla(string pad, BuyukKucuk siralama)
{
this.Sort(
delegate(Ogrenci o1, Ogrenci o2)
{
PropertyInfo prop1 = o1.GetType().GetProperty(pad);
PropertyInfo prop2 = o2.GetType().GetProperty(pad);
object v1 = prop1.GetValue(o1, null);
object v2 = prop2.GetValue(o2, null);
int val = Comparer.Default.Compare(v1, v2);
if (siralama == BuyukKucuk.Kucuk)
return val;
else
return -val;
}
);
}
}
class Ogrenci
{
private int _no;
public int No
{
get { return _no; }
set { _no = value; }
}
private string _ad;
public string Ad
{
get { return _ad; }
set { _ad = value; }
}
private DateTime _tarih;
public DateTime Tarih
{
get { return _tarih; }
set { _tarih = value; }
}
public Ogrenci(int a, string b, DateTime d)
{
Ad = b;
No = a;
Tarih = d;
}
public override string ToString()
{
return String.Format("Ad :{0} No : {1} Tarih : {2}", Ad, No, Tarih);
}
}
}
Categories:
C#
|
Code
Related posts:
Dinamik Assembly Yüklerken Bağımlılıkları Dikkate Almak Lazım
Güzel Bir Eğitimin Ardından
Dil yenilikleri ve Faydaları
C# Code Injection ( Bir Managed Exe ya da DLL'e Kod Ekleme)
C# 3.0 let keyword
(CodeFn) Registry ve Dosya Uzantısı Tanıtma
« PostBackUrl ve Yeni Sayfa
|
Home
|
Eğitim Sonu »
Friday, April 01, 2011 8:33:50 AM (GTB Daylight Time, UTC+03:00)
LQ4RGK <a href="http://ciyezzrvletg.com/">ciyezzrvletg</a>, [url=http://msalqtacfglk.com/]msalqtacfglk[/url], [link=http://rlapunpazgba.com/]rlapunpazgba[/link], http://ajgcssuwsesb.com/
uprerzsidn
|
lchsxnAT NOSPAMbkmvcx dot com
Saturday, April 23, 2011 2:14:36 PM (GTB Daylight Time, UTC+03:00)
Cialis ideiwp buy cialis viagra 1216
MarwinKun
|
presentsAT NOSPAMtomoe-ad dot com
Wednesday, April 27, 2011 12:49:12 PM (GTB Daylight Time, UTC+03:00)
car insurance quotes 8414 car insurance online wekqpm
spanoniem
|
infoAT NOSPAMvac-vision dot com
Friday, April 29, 2011 1:11:28 PM (GTB Daylight Time, UTC+03:00)
levitra shemale yasmin lee 61155 ultram online drugs 3848
contebz
|
hachimineAT NOSPAMh2 dot dion dot ne dot jp
Saturday, April 30, 2011 10:12:31 AM (GTB Daylight Time, UTC+03:00)
cheapest car insurance imjkg cheap car insurance >:-] buy auto insurance online gwcuz state auto insurance =-DD
ksherrod
|
bf8AT NOSPAMmage dot ocn dot ne dot jp
Name
E-mail
Home page
Remember Me
Comment (HTML not allowed)
Enter the code shown (prevents robots):
Live Comment Preview
Bilgi
BT Akademi
C#nedir?com
RSS/Subscribe
Archives
All dates
All Posts
Search
Latest Posts
HTTP Keep-Alive
Visual Studio 2010 Kullanıma Hazır
Sonunda ne olacak acaba?
INETA NEXT Türkiye Turu
Tech-ed 2009 Berlin Trilogy
Tech-ed 2009 Berlin Episode-II
Tech-ed 2009 Berlin Episode-I
WPF Web Semineri
Bir OOP & Design Patterns Eğitiminin Ardından
ASP.NET MVC 1.0 Semineri
Categories
.NET (53)
Asp.net (26)
C# (29)
Code (34)
dasBlog (1)
Inceleme (58)
Internet (35)
Yasam (37)
Archives
September, 2010 (1)
April, 2010 (1)
December, 2009 (2)
November, 2009 (4)
October, 2009 (2)
July, 2009 (1)
June, 2009 (2)
April, 2009 (1)
March, 2009 (1)
January, 2009 (7)
December, 2008 (1)
November, 2008 (6)
October, 2008 (2)
September, 2008 (3)
August, 2008 (4)
July, 2008 (6)
June, 2008 (3)
May, 2008 (1)
April, 2008 (1)
March, 2008 (4)
February, 2008 (2)
January, 2008 (6)
December, 2007 (1)
November, 2007 (3)
October, 2007 (5)
September, 2007 (8)
August, 2007 (7)
July, 2007 (4)
June, 2007 (1)
May, 2007 (6)
April, 2007 (6)
March, 2007 (9)
February, 2007 (9)
January, 2007 (6)
December, 2006 (6)
November, 2006 (5)
October, 2006 (16)
September, 2006 (12)
August, 2006 (20)
July, 2006 (7)
June, 2006 (2)
September, 2005 (2)
August, 2005 (1)
BlogRoll
Categories
.NET
Asp.net
C#
Code
dasBlog
Inceleme
Internet
Yasam
Contact the Author
oguz(nokta)yagmur(at)btakademi(nokta)com