我希望有一个使用整数数组作为键的字典,如果整数数组具有相同的值(甚至是不同的对象实例),它们将被视为相同的键.我该怎么办?
以下代码b不同,因为不同的对象实例.
int[] a = new int[] { 1, 2, 3 };
int[] b = new int[] { 1, 2, 3 };
Dictionary<int[], string> dic = new Dictionary<int[], string>();
dic.Add(a, "haha");
string output = dic[b];
Run Code Online (Sandbox Code Playgroud)