我有一个 xml 解析代码,我在其中解析来自 xml 的多个节点和属性。使用短路,我可以避免 if 在我的代码中,因为我只想在肯定的情况下继续处理。但是我收到 fxcop 错误CA1002
作为参数的使用。
如何删除 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)
{
}