Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- class InsertLineNumbers
- {
- // Write a program that reads a text file and inserts line numbers in front of each of its lines.
- // The result should be written to another text file.
- static void Main()
- {
- StreamReader reader = new StreamReader("Zada4a.txt");
- StreamWriter writer = new StreamWriter("Result.txt");
- int lineNumber = 1;
- string line = reader.ReadLine();
- while (line != null)
- {
- lineNumber++;
- writer.WriteLine("Line {0} {1}",lineNumber,line);
- line = reader.ReadLine();
- }
- reader.Close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment