Advertisement
elena1234

LineNumbers- with stream

Jan 14th, 2021
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3.  
  4. namespace LineNumbers
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             using (var reader = new StreamReader("input.txt"))
  11.             {
  12.                 using(var writer = new StreamWriter("output.txt"))
  13.                 {
  14.                     int lineNumbers = 1;
  15.                     while (!reader.EndOfStream)
  16.                     {
  17.                         var line = reader.ReadLine();
  18.                         writer.WriteLine($"{lineNumbers}. {line}");
  19.                         lineNumbers++;
  20.                     }
  21.                 }
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement