0

我正在尝试将一些 php 代码转换为asp.net代码

php代码:

        function setOption ($result) {
            foreach ($result as $value) {

                $parentid[$value['id']] = $value['parentid'];   
                $subid[$value['parentid']][] = $value['id'];    
                $name[$value['id']] = $value['name'];           
                $display[$value['id']] = $value['display'];         
            }           

            return array($parentid, $subid, $name, $display);

        } 

asp.net 代码

ArrayList al = new ArrayList();
    ArrayList parentid = new ArrayList();
    ArrayList subid = new ArrayList();
    ArrayList name = new ArrayList();
    ArrayList display = new ArrayList();

DataTable tbl = ds.Tables[0];
for (int i = 0; i < tbl.Rows.Count; i++)
{
    DataRow myRow = tbl.Rows[i];
    int id = Convert.ToInt32(myRow["id"]);
    int parent_id = Convert.ToInt32(myRow["parent_id"]);
    int oid = Convert.ToInt32(myRow["oid"]);
    int dis = Convert.ToInt32(myRow["display"]);
    string title = myRow["title"].ToString();

    parentid.Insert(id, parent_id);
    subid.Insert();
    name.Insert(id, title);
    display.Insert(id, dis);
}

al.Add(parentid);
al.Add(subid);
al.Add(name);
al.Add(display);

return al;

但是at$subid[$value['parentid']][] = $value['id'];是二维数组代码,asp.net如何在asp.net arraylist代码中呈现呢?

4

0 回答 0