惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
博客园 - 聂微东
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
F
Fortinet All Blogs
H
Help Net Security
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
L
LangChain Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium

博客园 - hateyoucode

http://tengine.taobao.org/ Mysql只Union用法 比较详细的mysql的几种连接功能分析,只要你看完就能学会的好东西 jq 判断单选是否选中 MSSQL中的bit类型 js 判断textarea 不为空 C# Split 分隔符为字符串及空格的处理 [转]asp.net中时间差的问题 [转]C# Array 数组 及 一些操作 [转]C#中out 及 ref 区别 [转]使用c# 模拟网站登录 RegisterStartupScript和RegisterClientScriptBlock的区别 asp+ajax asp中ajax的中文乱码 - hateyoucode - 博客园 css html span 块状不换行 我们应该明确几个问题 asp.net操作XML PHP Header用于页面跳转要注意的几个问题总结 - hateyoucode - 博客园 关于PHP header函数跳转的问题 - hateyoucode - 博客园 生成xml - hateyoucode - 博客园
asp.net 动态二维数组 - hateyoucode - 博客园
hateyoucode · 2010-07-27 · via 博客园 - hateyoucode

一:ArrayList存二维数组

为什么用ArrayList?
ArrayList是动态数组,可以在不知道长度的情况下声明和实力化,并且可以根据需要动
态增加长度,大小,删除任意索引位置的内容.这些都是普通数组无法办到的.

String[] get_num=new String[3];  //为了做您做例子随意搞个可爱的数组
get_num[0]="8,5,12,12";       
get_num[1]="82,52,52,42";
get_num[2]="18,35,112,132";

        ArrayList AL=new ArrayList();   //声明并实力化一个 傻傻的没吃饱的ArrayList
        ArrayList AL2 = new ArrayList();//声明并实力化一个 傻傻的没吃饱的ArrayList

        
        for (int i=0; i < get_num.Length; i++)
        {
           String[] get_numArray= get_num[i].Split(',');           //把普通数组按照","号切开
           for (int j = 0; j < get_numArray.Length; j++)
           {
              
               AL2.Add((double)(double.Parse(get_numArray[j])));  //这个例子值默认是double类
型的把第二维的内容加到AL2中

             
           }
          
               AL.Add((double[])AL2.ToArray(typeof(double)));//把第一维的内容加到AL中
               AL2.Clear();                  //清除内容以免下一次第二维重复累积

        }
      
     
          double[][] get_countNum=(double[][])AL.ToArray(typeof(double[]));  //OK!他吃饱了,AL被转
化成2维数组

自己写的

if (!IsPostBack)
        {
            string[] a = Common.DealersRol().Split(new char[] { ',' });
            ArrayList Al = new ArrayList();
            ArrayList Al2 = new ArrayList();
            for (int i = 0; i < a.Length; i++)
            {
                string[] b = a[i].Split(new char[] { '|' });
                for (int j = 0; j < b.Length; j++)
                {
                    Al2.Add((string)b[j]);
                }
                Al.Add((string[])Al2.ToArray(typeof(string)));
                Al2.Clear();
            }
            string[][] c = (string[][])Al.ToArray(typeof(string[]));
            DropDownList1.DataSource = c;
            DropDownList1.DataBind();
        }