3
虽然在方法声明中的FxCop违反使用IList<Dictionary<string, string>>
作为参数类型的FxCop违反泛型类型
它不窝泛型类型
IList<Dictionary<string, string>>
我怎样才能解决这个问题?
虽然在方法声明中的FxCop违反使用IList<Dictionary<string, string>>
作为参数类型的FxCop违反泛型类型
它不窝泛型类型
IList<Dictionary<string, string>>
我怎样才能解决这个问题?
原因是:
嵌套类型参数是类型参数,这也是一个通用的类型。 要调用其签名包含嵌套类型参数的成员, 用户必须实例化一个通用类型,并将此类型传递给另一个通用类型的构造函数 。所需的程序和语法是复杂的,应该避免。
它可以帮助您设计一个更简单的界面。你有三种情况:
SuppressMessage
属性你可以试试:
public void Method(Dictionary<string, string> param)
及用途:
var list = new IList<Dictionary<string, string>>();
list.Add(new Dictionary<string, string>{{"key1", "value1"}, {"key2", "value2"}});
list.Add(new Dictionary<string, string>{{"key11", "value11"}, {"key22", "value22"}});
foreach(var element in list)
{
Method(element);
}
请参阅[有没有对FxCop警告CA1006有什么好的解决方法?](http://stackoverflow.com/questions/417634/are-there-any-good-workarounds-for-fxcop-warning-ca1006) – Marusyk
此外[嵌套类型的替代表达式>](http://stackoverflow.com/questions/3441563/alternative-to-nested-type-of-type-expressionfunct) –
Marusyk
您可以创建一个包含列表的类,但是我会忽略这个规则。 –