开发者

Data Custom Array Groupping C#

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜