如何创建3D数组以及这是什么类型的数组? [英] How do I create 3D array and what type of array is this?

查看:137
本文介绍了如何创建3D数组以及这是什么类型的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用C#创建一个3D列表列表#



说我的数据就好像

I want to create a 3D array out of list in C #

Say my data is like

[{"axis":"NW","value":1.00},{"axis":"SW","value":1.00},{"axis":"EE","value":1.00}]





这是什么类型的数组?



What type of array is this?

var data = [
[//iPhone
{axis:"Battery Life",value:0.22},
{axis:"Brand",value:0.28},
{axis:"Contract Cost",value:0.29},
{axis:"Design And Quality",value:0.17},
{axis:"Have Internet Connectivity",value:0.22},
{axis:"Large Screen",value:0.02},
{axis:"Price Of Device",value:0.21},
{axis:"To Be A Smartphone",value:0.50}			
],
[//Samsung
{axis:"Battery Life",value:0.27},
{axis:"Brand",value:0.16},
{axis:"Contract Cost",value:0.35},
{axis:"Design And Quality",value:0.13},
{axis:"Have Internet Connectivity",value:0.20},
{axis:"Large Screen",value:0.13},
{axis:"Price Of Device",value:0.35},
{axis:"To Be A Smartphone",value:0.38}
],
[//Nokia Smartphone
{axis:"Battery Life",value:0.26},
{axis:"Brand",value:0.10},
{axis:"Contract Cost",value:0.30},
{axis:"Design And Quality",value:0.14},
{axis:"Have Internet Connectivity",value:0.22},
{axis:"Large Screen",value:0.04},
{axis:"Price Of Device",value:0.41},
{axis:"To Be A Smartphone",value:0.30}
]
];





我的尝试:





What I have tried:

List<HCP_Prfm_Chart> lstdtl = new List<HCP_Prfm_Chart>();
foreach (DataRow dr in ds.Tables[0].Rows)
{
lstdtl.Add(new HCP_Prfm_Chart
{
axis = dr["axis"].ToString(),
                
value = Convert.ToInt32(dr["value"])
});
}
HCP_Prfm_Chart[] Myarry = lstdtl.ToArray();
return Json(Myarry, JsonRequestBehavior.AllowGet);





如何从此函数返回此类型的数组< br $>




How can i return this type of array back from this function

[{"axis":"NW","value":1.00}],[{"axis":"SW","value":1.00}]

推荐答案

这称为JSON数据,是一种标准的tranmsfer格式,与XML相同,是或CSV。



见这里:从JSON中用0到英雄用C# [ ^ ]它描述了它非常有用,并向您展示了如何非常容易地处理有用的C#数据。
That is called "JSON Data" and is a standard tranmsfer format, in the same way that XML, is, or CSV.

See here: From zero to hero in JSON with C#[^] it describes it pretty weel, and shows you how to processit very easily into usefull C# data.


正如OriginalGriff所提到的,它是JSON数据。这是另一篇文章,更详细地讨论了如何使用JSON数据:使用C#中的JSON& VB [ ^ ]



本文还列出了许多有用的工具,例如从原始JSON自动生成C#/ VB代码...
As OriginalGriff mentioned, it is JSON data. Here is another article that discusses in more detail how to work with JSON data: Working with JSON in C# & VB[^]

The article also lists a number of useful tools for tasks like automatically generating C#/VB code from raw JSON...


这篇关于如何创建3D数组以及这是什么类型的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆