Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace Problem_1.Odd_Lines
- {
- class Program
- {
- static void Main(string[] args)
- {
- using (StreamReader stream = new StreamReader("Program.cs"))
- {
- /*
- Write a program that reads a text file and prints on the console its odd lines.
- Line numbers start from 0. Use StreamReader.
- */
- int counter = 0;
- string str = string.Empty;
- while ((str = stream.ReadLine()) != null)
- {
- if (counter % 2 ==1)
- {
- Console.WriteLine(str);
- }
- counter++;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment