Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a program that reads a text file containing a list of strings, sorts them and saves them to another text file.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- namespace _06.SortAndSaveInNewFile
- {
- class SortAndSaveInNewFile
- {
- static void Main(string[] args)
- {
- StreamReader read = new StreamReader(@"..\..\strings.txt");
- List<string> names = new List<string>();
- using (read)
- {
- names.Add(read.ReadToEnd());
- }
- foreach (var item in names.OrderBy(x => x.Length))
- {
- Console.WriteLine(item);
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement