I have the following list:
var menuList = new List<MenuItem>;
The first element of this List is:
menuList.Add(new List<MenuItem>)
I want to add an element of type MenuItem at the first position of the List which is in the another List.
I have the following list:
var menuList = new List<MenuItem>;
The first element of this List is:
menuList.Add(new List<MenuItem>)
I want to add an element of type MenuItem at the first position of the List which is in the another List.
 
    
     
    
    Reference : https://msdn.microsoft.com/en-us/library/sey5k5z4.aspx
public void Insert(
    int index,
    T item
)
 
    
    you are not permitted to Add/insert List<MenuItem> To menuList since it is defined as List<MenuItem> so that which will accept only MenuItem to form the required list. Don't worry you can achieve this by using List<List<MenuItem>> so that you can add/insert List<MenuItem>s to the  SuperMenu
List<MenuItem> menuList = new List<MenuItem>();
menuList.Add(new MenuItem() { Name = "a",..  });
menuList.Insert(0, new MenuItem() { Name = "B",.. });
List<List<MenuItem>> SuperMenu = new List<List<MenuItem>>();
SuperMenu.Add(menuList);
 
    
    This is the code for a list of lists...in other words a list having its items as lists
List<List<MenuItem>> menuItems = new List<List<MenuItem>>();
for (int i = 0 ; i < menuItems.Count();  i++)
{
   MenuItem itemToInsert; // "something";
   List<MenuItem> innerList = menuItems[1];//Returns inner list at index i
   innerList.Insert(0, itemToInsert);// Now insert anywhere you want
}
