System.Xml无需理由

tea*_*441 4 .net c#

protected override DataTable internalExecuteTable(string SQL)
{
    DbDataReader reader = ExecuteReader(SQL);
    DataTable dt = new DataTable();
    dt.Load(reader);
    reader.Close();
    return dt;
}
Run Code Online (Sandbox Code Playgroud)

"internalExecuteTable"带下划线并抛出一个错误,"System.Xml"未被引用,我应该添加"System.Xml"引用.但为什么?

我使用上面的代码从SQLite数据库中读取(System.Data.SQLite包装器)

Ant*_*ram 10

System.Xml间接使用.在DataTable具有当在所定义的类别依赖性System.Xml组件.如果您查看该类的文档,或者只是在IDE中进行浏览,您会注意到它包含许多用于读取和编写XML的方法.

通过使用System.Data.DataTable,您还需要参考System.Xml.

  • 在这种情况下,`DataTable`实现了`IXmlSerializable`接口,该接口位于System.Xml.dll中. (4认同)