2013-04-06 141 views
0

我想和参数的方法类似如何将嵌套字典作为参数传递给方法?

public int MyMethod(Dictionary<int, Dictionary<int,int>> myDict) 
{ 
... 
} 

但是写这个,我得到的编译失败消息,如下解释:

类型或命名空间名称Dictionary 2' 不能找到。

我该如何解决这个问题?

+8

你有'System.Collections中使用.Generic;'在文件顶部? – 2013-04-06 21:21:41

+0

不,我没有。谢谢! (也感谢编辑这个问题......) – user2253182 2013-04-06 21:26:57

回答

1

确保在文件顶部包含using System.Collections.Generic;。另外,您也可以使用完整的命名空间内联与您的代码:

public int MyMethod(System.Collections.Generic.Dictionary<int, System.Collections.Generic.Dictionary<int,int>> myDict) 
{ 

} 

(但我想我们可以从这个既看到using指令是更好一点)

相关问题