Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Menu{
- public int Section {get; set;}
- public string Parent {get; set;}
- public string Name {get; set;}
- public string Url {get; set;}
- /* more */
- }
- ILookup<int, ILookup<string, Menu>> MenuStructure =
- menuList.ToLookup(m => m.Section, menuList.ToLookup(m => m.Parent));
- ILookup<int, ILookup<string, Menu>> MenuStructure =
- menuList.GroupBy(m => m.Section).ToLookup(g => g.Key, v => v.ToLookup(m => m.Parent));
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class Program
- {
- class Menu {
- public int Section {get; set;}
- public string Parent {get; set;}
- public string Name {get; set;}
- public string Url {get; set;}
- }
- public static void Main()
- {
- var menuList = new List<Menu>();
- ILookup<int, ILookup<string, Menu>> MenuStructure =
- menuList.GroupBy(m => m.Section).ToLookup(g => g.Key, v => v.ToLookup(m => m.Parent));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement