列出每个键的多个值(List with multiple values per key)

我们如何创建一个包含多个值的列表,例如list [0]包含三个值{“12”,“String”,“someValue”} Some值与另外两个值相关联,我想使用列表而不是使用数组

string[, ,] read = new string[3, 3, 3];

how do we create a list with multiple values for example , list[0] contains three values {"12","String","someValue"} the Some value is associated to the two other values i want to use a list rather than using an array

string[, ,] read = new string[3, 3, 3];

最满意答案

为什么不有一个Tuple List ? 它可能不清楚,但它会做你以后的事情:

var list = new List<Tuple<string, string, string>>(); list.Add(new Tuple<string, string, string>("12", "something", "something"));

尽管给这些值赋予语义含义可能会更好。 也许如果你让我们知道这些价值观想要展示什么,那么我们可以给出一些关于如何使它更具可读性的想法。

Why not have a List of Tuple's? It can be unclear, but it will do what you are after:

var list = new List<Tuple<string, string, string>>(); list.Add(new Tuple<string, string, string>("12", "something", "something"));

Although it would probably be better to give these values semantic meaning. Perhaps if you let us know what the values are intending to show, then we can give some ideas on how to make it much more readable.

列出每个键的多个值(List with multiple values per key)

我们如何创建一个包含多个值的列表,例如list [0]包含三个值{“12”,“String”,“someValue”} Some值与另外两个值相关联,我想使用列表而不是使用数组

string[, ,] read = new string[3, 3, 3];

how do we create a list with multiple values for example , list[0] contains three values {"12","String","someValue"} the Some value is associated to the two other values i want to use a list rather than using an array

string[, ,] read = new string[3, 3, 3];

最满意答案

为什么不有一个Tuple List ? 它可能不清楚,但它会做你以后的事情:

var list = new List<Tuple<string, string, string>>(); list.Add(new Tuple<string, string, string>("12", "something", "something"));

尽管给这些值赋予语义含义可能会更好。 也许如果你让我们知道这些价值观想要展示什么,那么我们可以给出一些关于如何使它更具可读性的想法。

Why not have a List of Tuple's? It can be unclear, but it will do what you are after:

var list = new List<Tuple<string, string, string>>(); list.Add(new Tuple<string, string, string>("12", "something", "something"));

Although it would probably be better to give these values semantic meaning. Perhaps if you let us know what the values are intending to show, then we can give some ideas on how to make it much more readable.