我有一個xml解析代碼,我從xml解析多個節點和屬性。如果在我的代碼中使用短路,我可以避免,因爲我只想在正面情況下繼續處理。但我得到fxcop錯誤CA1002
參數作爲用法。在條件流和CA1002 fxcop錯誤中使用out參數
我該如何刪除fxcorp錯誤?
public bool parseNode()
{
bool success = false;
string val1;
string val2;
string val3
success = TryGetAttributeValue(attribName1, out val1) &&
TryGetAttributeValue(attribName2, out val2) &&
TryGetAttributeValyue(attribName3, out val3);
if(success)
{
// do work
}
}
public bool TryGetAttributeValue(string attribName, out string value)
{
}
CA1002似乎是「不要公開通用名單」。 http://msdn.microsoft.com/en-us/library/ms182142.aspx你確定這是正確的錯誤代碼? CA1021,「避免參數」? http://msdn.microsoft.com/en-us/library/ms182131.aspx – BACON 2012-03-10 05:55:48