本文介绍了重构XmlTextWriter,偏执的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重构以下代码:

I''m refactoring the following code:

using (StreamReader stream = new StreamReader(InputFilePath))
{
    XmlTextReader xmlIn = new XmlTextReader(stream);
    while (xmlIn.Read())
    {
        //Do stuff
    }
    xmlIn.Close();
}



首先,我有点偏执,想检查以下内容是否会起作用,因为我不确定为什么原来没有这样做:



First I''m, being a bit paranoid and want to check if the following will behave, as I''m unsure why this wasn''t done in the originally:

using (XmlTextReader xmlIn = new XmlTextReader(new StreamReader(inputFilePath)))
{
    while (xmlIn.Read())
    {
        //Do stuff
    }
}



其次,我也很清楚地记得,有一种比新的XmlTextReader(new StreamReader(inputFilePath))
更加整洁的方法.实例化,如果我没错,建议会很有用.

谢谢.



Secondly, I also vauguely remember there is a neater way than the new XmlTextReader(new StreamReader(inputFilePath))
instantiation, if I''m right suggestions would be useful.

Thanks.

推荐答案


这篇关于重构XmlTextWriter,偏执的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 23:40
查看更多