0

我一直在努力将一些数据分组到这种格式的数组中:

http://pastebin.com/dxkCnzq3

如果你感到困惑,它会是这样的(类型数)

 new Array[Bool(2)][Bool(2)][Byte(3)][String(X)]

其中字符串的数量是动态的,而其他的则是固定的。

有没有办法在 c# 中实现这一点?

任何帮助表示赞赏

4

2 回答 2

1

据我了解,你需要树结构。您可以使用其中一些解决方案:

或者自己创建树结构:

class Byte
{
    byte value;
    string[] strings;
}

class Bool<T> where T: class
{
   bool value
   List<T> array;
}

而不是使用它:

Bool<bool> b1 = new Bool();
b1.array.Add(new Bool<Byte>());

等等...

于 2011-10-04T18:26:06.937 回答
1

听起来你可以使用元组

var dict = new Dictionary<Tuple<bool, bool, bool, bool, int, int, int>, string[]>();
dict[Tuple.Create(true, true, false, false, 2, 3, 5)] = new[] { "test", "pest" };
于 2011-10-04T18:38:02.800 回答