Multi-dimensional arraylist or list in C#?

前端 未结 5 1810
面向向阳花
面向向阳花 2020-12-03 00:07

Is it possible to create a multidimensional list in C#? I can create an multidimensional array like so:

 string[,] results = new string[20, 2];
5条回答
  •  误落风尘
    2020-12-03 00:38

    you just make a list of lists like so:

    List> results = new List>();
    

    and then it's just a matter of using the functionality you want

    results.Add(new List()); //adds a new list to your list of lists
    results[0].Add("this is a string"); //adds a string to the first list
    results[0][0]; //gets the first string in your first list
    

提交回复
热议问题