Search This Blog

Thursday, December 30, 2010

How to create a list to store 2 variables

Define variables:

        string _tag;
        string _name;

Create list:

        //set list to store tag & name of menu item
        public static List<Tuple<string, string>> menuStructure = new List<Tuple<string, string>>();

Save variables to list:

        //save menu structure for future use in permissions granting program
        Session.menuStructure.Add(new Tuple<string, string>(_tag, _name));

Sort list by Name:

        //sort menu structure by name
        Session.menuStructure.Sort((a, b) => a.Item1.CompareTo(b.Item1));

No comments:

Post a Comment