Search code examples
c#listtypescollectionsgenerics

How can I shorten List<List<KeyValuePair<string, string>>>?


I want to store an list of key value pair lists in a structure. This seems too cumbersome to type. What's better? Does the text List<Dictionary<string, string>> add much overhead? What other options are available?


Solution

  • Consider using aliasing for shorthand:

    namespace Application
    {
        using MyList = List<List<KeyValuePair<string, string>>>;
    
        public class Sample
        {
            void Foo()
            {
                var list = new MyList();
            }
        }
    }