I've been struggling to group some data into an array of this format:

http://pastebin.com/dxkCnzq3

In case your confused it would be something like this (number of type)

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

Where the number of strings is dynamic, and the else are fixed.

Is there any way to achieve this in c#?

Any help appreciated

有帮助吗?

解决方案

It kind of sounds that you could use a Tuple

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" };

其他提示

As i understand u need tree structure. You can use some of these solutions: one, two, three, four.

Or create the tree structure by self:

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

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

And than use it:

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

And so on...

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top