Multidimensional List C#

arrays, c#, list, multidimensional-array

Solution

If you need to create a multidimensional list, you can always create a list of lists like so:

var multiDimensionalList = new List<List<string>>{
    new List<string>{"A","B","C"},
    new List<string>{"D","E","F"},
    new List<string>{"G","H","I"},
};
Console.WriteLine(multiDimensionalList[2][1]); // Prints H

multiDimensionalList[2].RemoveAt(1);
Console.WriteLine(multiDimensionalList[2][1]); // Prints I

multiDimensionalList[2][1] = "Q";
Console.WriteLine(multiDimensionalList[2][1]); // Prints Q

Be aware though that attempting to replace a value that doesn't exist by way of assignment will throw an exception:

multiDimensionalList[2][5] = "R"; // Throws an ArgumentOutOfRangeException

Problem

I need to create a multidimensional guard List three values​​, X, Y and Z, and I need a List that is because once the value is queried, the array must be removed. The query would look something like this: List [0] [0] = X, List [0] [a] = Y and List [0] [2] = X, so that I can remove only the index 0 and he already remove all the other three.

Original source