What’s the difference between Response.Write() and Response.Output.Write()?

若如初见. 提交于 2019-12-01 03:17:05

问题


What’s the difference between Response.Write() and Response.Output.Write()?


回答1:


There is effectively no difference, although Response.Output.Write() provides more overloads which can allow you to pass different parameters. Scott Hansleman covers it in depth.




回答2:


They both write to the output stream using a TextWriter (not directly to a Stream), however using HttpContext.Response.Output.Write offers more overloads (17 in Framework 2.0, including formatting options) than HttpContext.Response.Write (only 4 with no formatting options).

The HttpResponse type does not allow direct 'set' access to its output stream.




回答3:


Nothing really.

But. Response.Write takes the stream in the Response.Output property. You could set another Output stream, and in that way instead of writing back to the client, maybe write to a file or something crazy. So thats there relation.




回答4:


Response.Output.Write(): It is used to display any type of data like int, date, string etc. i.e. It displays the formatted output.

Response.Write(): To display only string type of data i.e. It's can't display formatted output().

To display formatted output from Response.Write() you can write:

Response.Write(String.Format("    ",___));


来源:https://stackoverflow.com/questions/111417/what-s-the-difference-between-response-write-and-response-output-write

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!