【发布时间】:2016-03-31 23:39:03
【问题描述】:
在 PHP5 中,我将一些数组声明为
$secArray0 = array();
$secArray1 = array();
$secArray2 = array();
$secArray3 = array();
$secArray = array();
稍后在代码中的某些地方,我在上述数组中插入键值对
$pHolder0 = array(
'Name' => 'Gomesh',
'EmpCode' => 'ID04',
'DeptId' => '1C',
'Age'=> '25'
);
array_push($secArray0,$pHolder0);
$secArray1、$secArray2、$secArray3 以此类推。
最后我在 $secArray 中插入 $secArray0,$secArray1....$secArray3 as
$secArray = array($secArray0,$secArray1,$secArray2,$secArray3);
现在我的问题是我可以在 C# 中完成这样的事情吗?
到目前为止,我已经完成了..
var secArray0 = new List<KeyValuePair<string, string>>();
secArray0.Add(new KeyValuePair<string, string>("Name", "gomesh"));
secArray0.Add(new KeyValuePair<string, string>("EmpCode", "ID04"));
secArray0.Add(new KeyValuePair<string, string>("DeptId", "1C"));
secArray0.Add(new KeyValuePair<string, string>("Age", "25"));
依此类推,直到 secArray3。但是如何在 secArray 中插入 secArray0、secArray1、secArray2、secArray3?就像上面解释的 PHP 代码一样。
【问题讨论】:
-
对
secArray0使用Dictionary<string, string>,对secArray使用Dictionary<string, string>[]。 -
你能详细解释一下如何做......Dictionary
[] for secArray
标签: c# php arraylist multidimensional-array