Friday 15 March 2013

c# - OrderByDescending() per MSDN, what on earth does this mean? -


Can someone please help in separating the elements here and help me understand what they are?

  public static IOrderedEnumerable & lt; TSource & gt; Order-bizdetting & lt; TSource, TKey & gt; (This IEnumerable & lt; TSource & gt; source, Func & lt; TSource, TKey & gt; key selector)  

What is TSource and TKey? What is a major selector? What is IOrderedEnumerable?

What does Func>

Why is MSDN so secret?

breakdown

  • tsros: the type of elements in this collection is , Which needs to be ordered
  • TK: The type of key by which the elements are ordered.
  • Func & lt; TSource, TKey & gt; : The representative who will return a key for the given element in the collection

This function is basically a sorting function such as it needs a way to compare the elements of the collection. This particular method assumes that there is a similar key value for a given object by which it can be sorted.

For example, take a low grade student

  class student {string name {get; Set; } ...}  

If I want to sort the collection of student examples by their name then I can do the following:

  IEnumerable & LT; Students & gt; Col = GetTheStudents (); Ordered var = col.OrderByDescending (x => x.Name);  

The values ​​in this case will be as follows:

  • TSORS: student
  • vaccine: String
  • Func & lt; TSource, TKey & gt; : This has been passed in Lambda expression x = & gt; X.Name

No comments:

Post a Comment