【C#】各種型別的Copy方法

  • 3980
  • 0

摘要:【C#】各種型別的Copy方法

 

1. Array


int[] a = new int[6] { 1, 2, 3, 4, 5, 6 };
int[] b;

b = new int[b.Length];
a.CopyTo(b, 0);

 

2. Dictionary


Dictionary strDic = new Dictionary();
Dictionary strDic2;
strDic.Add(1, "1");
strDic.Add(2, "2");

strDic2 = new Dictionary(strDic);