C#: Sorting with anonymous function -
Let's say I have a list of objects, and I want to sort it according to the date dated property. Why can not one use a representative? How do I sort them by date dated if not as shown below:
Sort public stringDated (list & gt; CartItem & gt; items) {items.Sort (new function & quot; Cart item, Cart item, Bold & gt; ((itemA, Item B) = & gt; {Return Item A.Detted; Item BaidDate;});); }
Why not use lambda expressions?
public string sorted by date (list & gt; item); items (. (A, b) = & gt; a.DateModified.CompareTo (b.DateModified)); }
Comments
Post a Comment