Saturday, April 05, 2008

How to perform Sort operation in List Generic List

Today I am coming with a small but efficient code for performing Sort operation in List. I am not going to explain it in much details as the code is

self understandable.

List braList;

braList = _branManager.GetBranchList();



delegate(Branch braA, Branch braB)


if (CompanySortDirection == SortDirection.Ascending)


return braA.BranchCode.CompareTo(braB.BranchCode);


else// if (CompanySortDirection == SortDirection.Descending)


return braB.BranchCode.CompareTo(braA.BranchCode);




Depending upon the Sort Direction the list get sorted.

No comments:

Post a Comment