Improve your skills

May 23, 2017

Difference Between Response.Write() and Response.Output.Write()

Response.Write() and Response.Output.Write() both are used for print output on the screen.
But their are some differences between both of them-

Response.Write()
  1. Output is written in text stream.
  2. Response.Write() is used to display only string (Normal Text). It can't allows the formatted output.
  3. As Per Asp.Net 3.5, Response.Write() Has 4 overloads.
  4. We can't display any other data type values like int, date etc. Conversion(from one data type to another) is not allowed.
  5. Example:
    Response.Write("Hello ASP.NET");
    Response.Write("Current Date Time is " + DateTime.Now.ToString());

Response.Output.Write()

  1. Output is written in HTTP Output Stream.
  2. Response.Output.Write() is allows us to print formatted output. formatted output needs to argument based on which the output will be formatted.
  3. As Per Asp.Net 3.5, Response.Output.Write() has 17 overloads.
  4. We can display any type of data like int, date, string etc. by giving index values.
  5. Example: 
    Response.Output.Write("{0} is {1:d}", "Current Date Time is: ", DateTime.Now);





0 comments:

Post a Comment

Subscribe for Latest Update

Popular Posts