DCSIMG
Using ToOrder and ToDictionary - שלמה גולדברג (הרב דוטנט)

שלמה גולדברג (הרב דוטנט)

מרצה בסלע ויועץ בעולם ה - net.

Using ToOrder and ToDictionary

 

דוגמת שימוש למיון Dictionary.

 
נניח שיש לכם פונקציה שמחזירה Dictinoary
 

private static Dictionary<string, int> GetLeftTabsDefinition()

{

    Dictionary<string, int> tabs = new Dictionary<string, int>()

    {

       {"ShowInfo", 2},

       {"ShowResources", 1 },

       {"ShowTOC", 3  },

    };

 

    return tabs;

}

 
כעת קבלתם את האובייקט
 

var tabs = GetLeftTabsDefinition();

 
ואתם רוצים למיין אותו - הקוד צריך להיראות כך.
 

tabs = tabs.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

פורסם: Jul 06 2010, 11:32 AM by Shlomo | with 2 comment(s)
תגים:, ,

תוכן התגובה

Shlomo כתב/ה:

לא ככה צריך לכתוב נראה מוזר אבל זה המציאות

# July 15, 2010 12:05 PM
שלח תגובה

(שדה חובה)  

(שדה חובה)  

(אופציונלי)

(שדה חובה) 

Please add 5 and 7 and type the answer here:


Enter the numbers above: