Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace linq
- {
- using System.IO;
- internal class Program
- {
- public static string[] GetAllStrings(string path)
- {
- string k;
- using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
- using (StreamReader sw = new StreamReader(fs))
- {
- k = sw.ReadToEnd();
- }
- return k.Split('\n');
- }
- public static void Main(string[] args)
- {
- string [] words = GetAllStrings("/Users/renurt/RiderProjects/files_refresh/wordlist.txt");
- IEnumerable<string> beginsWithBa = from n in words where n.StartsWith("ba") where n.Length>2 orderby n[n.Length-2], n.Length descending select n;
- foreach (var word in beginsWithBa)
- {
- Console.WriteLine(word);
- }
- IEnumerable<IGrouping<int, string>> containsCan = from n in words where n.Contains("can") group n by n.IndexOf("can");
- foreach (IGrouping<int, string> group in containsCan)
- {
- Console.WriteLine(group.Key+":");
- foreach (string word in group)
- {
- //Console.WriteLine(word);
- }
- }
- var OK = from n in words
- where n.Contains("su")
- from k in new int[] {1, 2}
- select k + n
- into l
- where l[1] == 'r'| l[1] == 'm'
- orderby l.Length group l by l.Length;
- foreach (var group in OK)
- {
- Console.WriteLine(group.Key + ":");
- foreach (string word in group)
- {
- Console.WriteLine(word);
- }
- }
- var mk = words.Where(t => t.StartsWith("nas"));
- double s = 4.34234;
- Console.WriteLine($"{s:0.0010}");
- Console.WriteLine($"{s:f2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement