Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/334.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# C创建int和数组字典_C#_.net_Dictionary - Fatal编程技术网

C# C创建int和数组字典

C# C创建int和数组字典,c#,.net,dictionary,C#,.net,Dictionary,如何创建包含int作为键和数组作为值的字典。以下是我在dotnetfiddle.net上尝试的内容,但运气不佳: Dictionary<int, double[]> dict; double[] prices = new double[20]; dict = new Dictionary<int, prices>(); Dictionary<int, double[]> dict; dict = new Dictionary<int, new doub

如何创建包含int作为键和数组作为值的字典。以下是我在dotnetfiddle.net上尝试的内容,但运气不佳:

Dictionary<int, double[]> dict;
double[] prices = new double[20];
dict = new Dictionary<int, prices>();

Dictionary<int, double[]> dict;
dict = new Dictionary<int, new double[20]>();

Dictionary<int, double[]> dict;
dict = new Dictionary<int, double[20]>();
你可以试试这个

Dictionary是泛型类型,您只能在其上设置合同类型

我认为您正在寻找Add方法来添加双数组

你可以试试这个

Dictionary是泛型类型,您只能在其上设置合同类型

我认为您正在寻找Add方法来添加双数组

Dictionary dict=新字典?Dictionary dict=新字典?
Dictionary<int, double[]>  dict = new Dictionary<int, double[]>();
dict.Add(1,new double[20]);