[Quote=引用 1 楼 ljhcy99 的回复:]
int [] d1= {1,2};
int [] d2= {3,4};
List <int> ls= new List <int>();
foreach(int i in d1)
{
ls.Add(i);
}
foreach(int i in d2)
{
ls.Add(i);
}
int []d3= ls.ToArray();
[/Quote]
如果一定要这样写,这样写效率会更高
int [] d1= {1,2};
int [] d2= {3,4};
List <int> ls= new List <int>(d1);
ls.AddRange(d2);
int []d3= ls.ToArray();
int [] d1= {1,2};
int [] d2= {3,4};
List<int> ls= new List<int>();
foreach(int i in d1)
{
ls.Add(i);
}
foreach(int i in d2)
{
ls.Add(i);
}
int []d3= ls.ToArray();