关于如何一个定义变量

eaichina 2008-04-30 11:39:41
这样的变量,如下;
json[0][0][width]=96
json[0][0][height]=96
json[0][0][realpath]=../UserFiles/c1a5593186a75f86133291917d08f968/080429115536.jpg
json[0][0][x]=160
json[0][0][y]=134
json[0][0][zindex]=1
我想定义json,我用string[][][] jason;结果出错:第3个[]内必须为int值;
谁知道在C#.NET怎么定义这个json,谢谢
...全文
138 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jamesfay 2008-04-30
  • 打赏
  • 举报
回复
string [][][] xxx = new string[][][] {xxxx}
virusswb 2008-04-30
  • 打赏
  • 举报
回复
什么意思,三维数组吗
可以使用字典嵌套
dictionary<int,dictionary>
里面的dic又是一个<int,string>
yunfeng007 2008-04-30
  • 打赏
  • 举报
回复

struct json
{
public int width;
public int height;
public string realpath;
public int x;
public int y;
public int zindex ;
}


还有干什么要定义成3维数组啊?
Kevin_LiuFeng 2008-04-30
  • 打赏
  • 举报
回复
最好还是定义一个类吧,C#里面少用Struct
yatobiaf 2008-04-30
  • 打赏
  • 举报
回复
你的realpath这个东西是个字符串啊,怎么能放到int数组里呢?
最好的办法就是定义一个struct

public struct Json
{
int width;
int height;
string realpath;
int x;
int y;
int zindex;
}

Json [][] json = new Json [10][10];
onthebox 2008-04-30
  • 打赏
  • 举报
回复
数组的维数过多
可以重新考虑数据的结构
eaichina 2008-04-30
  • 打赏
  • 举报
回复
上面的都不可以,谁还可以在帮忙啊?!
  
string item = Base64Decode(Request["item"]);
string info = Base64Decode(Request["info"]);
string[] Arrayinfo = info.Split(',');
int key = 0;
int skey = 0;
foreach (string first in Arrayinfo)
{
key++;
if (first != "")
{
string[] s = first.Split(new char[2] { '|','|'});
foreach (string second in s)
{
skey++;
if (second!= "")
{
string[] t = second.Split('|');
foreach (string third in t)
{
string[] f = third.Split(':');
json[key][skey][f[0]] = f[1].ToString();
Response.Write("<br>json["+key+"]["+skey+"]["+f[0]+"] = "+f[1].ToString());
}
}

}
}
}

我想得到下面的
json[0][0][width]=96
json[0][0][height]=96
json[0][0][realpath]=../UserFiles/c1a5593186a75f86133291917d08f968/080429115536.jpg
json[0][0][x]=160
json[0][0][y]=134
json[0][0][zindex]=1

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧