This comment is incorrect:
// We must declare the variable outside of the using block
// so that it is in scope to be returned.
The example works just fine like this:
using (var file = new System.IO.StreamWriter("WriteLines2.txt"))
{
int skippedLines = 0;
foreach (string line in lines)
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.