简体   繁体   English

在 C# 中重新创建这个数组的最佳解决方案是什么?

[英]Whats the best solution to recreate this array in c#?

I tried many things but im not happy with the result, so i decided to ask: How can i recreate this array in c#?我尝试了很多东西,但我对结果不满意,所以我决定问:如何在 c# 中重新创建这个数组?

local itemTable = {

["category1"] = {
    {"Test1",1463,0.4,0,13},
    {"Test2",1578,0.5,0,4},
    {"Test3",2683,1,0,6},
},

["category2"] = {
    {"Test4",328,0.4,90,5},
    {"Test5",1463,0.4,0,5},
    {"Test6",346,1,90,1.5},
},}

Btw.顺便提一句。 this array is from LUA.这个数组来自LUA。

You didn't mention how you want to use the data, however I would do it this way:你没有提到你想如何使用数据,但我会这样做:

var dict = new Dictionary<string, Dictionary<string, List<double>>>()
{
    { "category1", new Dictionary<string,List<double>>()
        {
            { "Test1", new List<double>{ 1463, 0.4, 0, 13 } },
            { "Test2", new List<double>{ 1578, 0.5, 0, 4 } },
            { "Test3", new List<double>{ 2683, 1, 0, 6 } },
        }
    },

    { "category2", new Dictionary<string,List<double>>()
        {
            { "Test4", new List<double>{ 328, 0.4, 90, 5 } },
            { "Test5", new List<double>{ 1463, 0.4, 0, 5 } },
            { "Test6", new List<double>{ 346, 1, 90, 1.5 } },
        }
    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM