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
您可以創建一個包含列表的類,但是我會忽略這個規則。 –