c# 3.0 - Sorting Generic List in C# -



c# 3.0 - Sorting Generic List in C# -

i have generic list shown in below.

list<usrprofile> lst = getusers(); lst.sort(); ddluser1.datasource = lst; ddluser1.databind();

now dropdown has both value , text. sort text using generic list.

please help. cannot utilize linq

if understand question correctly (and may not...it's not clear), want sort list specific fellow member of usrprofile class. specifically, text property.

this easy do: lst.sort((u1, u2) => u1.text.compareto(u2.text)); should want.

this passes comparison<usrprofile> delegate instance list<usrprofile>.sort() method, allowing customize comparing logic used sort. in case, rather comparing whole usrprofile objects against each other, compares text property between objects.

c#-3.0 asp.net-3.5

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -