StringBuilder vs XmlTextWriter

前端 未结 4 1268
独厮守ぢ
独厮守ぢ 2020-12-31 15:57

I am trying to squeeze as much performance as i can from a custom HttpHandler that serves Xml content.

I\' m wondering which is better for performance. Using the Xm

4条回答
  •  长情又很酷
    2020-12-31 16:12

    Honestly until you really, really, really, really, really need to care about performance... don't.

    Go with the more maintainable solution first, and only compromise when performance becomes a measurable issue. XmlTextWriter offers you the benefit of "Knowing" about how Xml is supposed to work. StringBuilder does not, and is therefore error prone. You don't want to spend a day tracking down a malformed node somewhere in your gnarly stringbuilder code.

    Let the framework work for you.

提交回复
热议问题