asp.net - sorting list of custom classes using linq -
i have custom class
class item public item string public descrip string public cost string public bin string public total decimal public qty integer end class
now have class
public class default3 inherits system.web.ui.page dim c int16 = 0 dim item3 new item dim item2 new list(of item)
now adding items in item2 of type item
item3.item = string.format(record(0)) ' field "item" item3.descrip = string.format(record(1)) ' field "descrip" item3.price = string.format(record(2)) ' field "price" item3.bin = string.format(record(3)) ' field "bin" item2.add(item3)
now how can sort elements in item2 according item3.bin? thanks
use orderby
item2 = item2.orderby(function(x) x.bin).tolist()
or can utilize sort
item2.sort(function(x, y) x.bin.compareto(y.bin))
asp.net .net vb.net linq
No comments:
Post a Comment