Creative Jar Blog RSS Feed

List<WhateverObjectYouWant> Stucture

June 2, 2008 14:17 by tim

I'm getting right into using these List<> objects from System.Collections.Specialized.  Very quick compared to DataTables and they can even wrap up your custom objects and make them immediataly bindable to your DataBound controls on the form.  They populate really easily from LINQ queries as well so you can throw your custom strongly-type object around all over the place and everything is tight when compiling :¬)

The only thing i couldn't quite grasp was sorting. Before i saw this ( http://www.jonasjohn.de/snippets/csharp/sort-enumerable-list.htm ), I would resort to going back to DataViews and then using the sort function on there

I think I was missing some syntax knowledge when I looked at this previously but you can use any key on your objects you like, like so :

lstClean.Sort(delegate(LPDataAccess.AgeRange A, LPDataAccess.AgeRange B) { return A.AgeCode.CompareTo(B.AgeCode); });

Damn fine use of delegates there :¬)


Be the first to rate this post

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

Related posts

Add comment


 

  Country flag

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



Live preview

January 6. 2009 01:56

Calendar

January 2009
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567