Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class Menu{
  2. public int Section {get; set;}
  3. public string Parent {get; set;}
  4. public string Name {get; set;}
  5. public string Url {get; set;}
  6. /* more */
  7. }
  8.  
  9. ILookup<int, ILookup<string, Menu>> MenuStructure =
  10. menuList.ToLookup(m => m.Section, menuList.ToLookup(m => m.Parent));
  11.  
  12. ILookup<int, ILookup<string, Menu>> MenuStructure =
  13. menuList.GroupBy(m => m.Section).ToLookup(g => g.Key, v => v.ToLookup(m => m.Parent));
  14.  
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18.  
  19. public class Program
  20. {
  21. class Menu {
  22. public int Section {get; set;}
  23. public string Parent {get; set;}
  24. public string Name {get; set;}
  25. public string Url {get; set;}
  26. }
  27.  
  28. public static void Main()
  29. {
  30. var menuList = new List<Menu>();
  31.  
  32. ILookup<int, ILookup<string, Menu>> MenuStructure =
  33. menuList.GroupBy(m => m.Section).ToLookup(g => g.Key, v => v.ToLookup(m => m.Parent));
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement