您的位置:程序门 -> .net技术 -> c#



c#中如何访问三维数组元素?在线等待!!!!!thank you very much!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


c#中如何访问三维数组元素?在线等待!!!!!thank you very much![已结贴,结贴人:jason_steven]
发表于:2007-03-06 09:45:13 楼主
int[,   ,]   array3d   =   new   int[,,]   {   {   {   1,   2,   3   }   },   {   {   4,   5,   6   }   }   };
console.writeline( "the   elements   of   the   3   dimensional   array   are  
                                          {0}   {1}   {2}   {3}   {4}   {5}. ",
                                        array3d[0][0][0],  
                                        array3d[0][0][1],  
                                        array3d[0][1][0],  
                                        array3d[0][1][1],
    array3d[0][2][0],  
                                        array3d[0][2][1]);
编译时,提示如下error:
[]   内索引数错误,应为“3”

点击错误时,提示指向了第二维索引

发表于:2007-03-06 10:05:421楼 得分:20
和定义时一样写

array3d[0,0,0]

   
*****************************************************************************
欢迎使用csdn论坛专用阅读器   :   csdn   reader(附全部源代码)  

最新版本:20070212

http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
发表于:2007-03-06 10:34:462楼 得分:0
int[,   ,]   array3d   =   new   int[0,3,2]  
array3d[0,0,0]=1;
array3d[0,0,1]=2;
......
发表于:2007-03-06 10:38:543楼 得分:0
数组变量需要提前定义好个数
int[]   a   =   new   int[]   ----错误
int[]   a   =   new   int[3]   ---正确
发表于:2007-03-06 10:48:254楼 得分:0
详细一点
发表于:2007-03-06 10:51:065楼 得分:0
jone_fox()的声明是错误的
正确:the   length   of   the   first   dimension   is   2
          the   length   of   the   second   dimension   is   1
          the   length   of   the   first   dimension   is   3

int[,,]   array3d   =   new   int[2,1,3]   {   {   {   1,   2,   3   }   },   {   {   4,   5,   6   }   }   };
console.writeline( "the   elements   of   the   3   dimensional   array   are   :
                                        {0}   {1}   {2}   {3}     {4}   {5}. ",  
      array3d[0,0,0],  
                                          array3d[0,0,1],  
                                          array3d[0,0,2],  
                                          array3d[1,0,0],
      array3d[1,0,1],  
                                          array3d[1,0,2]);
请大家放心,上面的代码已运行通过!!!


发表于:2007-03-06 13:01:206楼 得分:0
sorry,没仔细看.
但表达的主要意识就是: "数组变量需要提前定义好个数 ".
发表于:2007-06-25 21:44:137楼 得分:0
谢谢楼上的~
请问怎么样导入dxf格式的三维数据呢??


快速检索

最新资讯
热门点击