Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Others have said already, but it is because they derive from TextReader/TextWriter and can be used in place of them. For one thing it just makes more sense to use the same method for outputting lines that you use for a file if you only want the content as a string. If you want output that will span multiple lines in memory, why bother remembering to put "\r\n" at the end of every line with a StringBuilder? What if you want the code to run on or format data for a system that only uses "\n" for line breaks? </p> <pre><code>StringBuilder sb = new StringBuilder(); // will be invalid on systems that only use \n sb.AppendFormat("{0:yyyy-MM-dd HH:mm:ss} - Start\r\n", DateTime.Now); // still have to add an extra parameter sb.AppendFormat("The current time is {0:yyyy-MM-dd HH:mm:ss}{1}", DateTime.Now, Environment.NewLine); StringWriter sw = new StringWriter(); // Don't have to worry about it, method name tells you there's a line break sw.WriteLine("{0:yyyy-MM-dd HH:mm:ss} - Start", DateTime.Now); // no extra parameters sw.WriteLine("The current time is {0:yyyy-MM-dd HH:mm:ss}", DateTime.Now); </code></pre> <p>Say you want to process a file line by line, you would probably use a StreamReader instead of loading the whole file into a StringBuilder and splitting it by newline characters into an array, right? With StringReader you can use the exact same method (as long as it takes a generic TextReader) by creating the StringReader from a string from a TextBox or web form.</p> <p>Linq2Sql DataContexts have a Log property you can set to a TextWriter to have your queries output before they are executed to see exactly what is being run. You can set this to a TextWriter attached to a file, but you could attach a StringWriter to it and output the contents at the bottom of your web page when testing...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload