There is a class in which the method should output the number of words consisting of n characters from a text file.
//Открывает файл private async void ButtonBrowse_Click(object sender, RoutedEventArgs e) { FileOpenPicker openPicker = new FileOpenPicker(); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; openPicker.FileTypeFilter.Add(".txt"); StorageFile file = await openPicker.PickSingleFileAsync(); if (file != null) { LabelPath.Text = file.Path; TextFile.Text = await Windows.Storage.FileIO.ReadTextAsync(file); } else { // } } private void ButtonCount_Click(object sender, RoutedEventArgs e) { LabelNCount.Text = "Number of n-count words: " + CountClass.nCount(TextFile.Text, Int32.Parse(TextNCount.Text)); } //Метод из класса CountClass, в котором должен происходить подсчёт public static int nCount(String file, int numberOfCharacters) { return file.Split('\n').Count(line => line.Length > numberOfCharacters); //это или не работает, или лыжи не едут } There are no problems with counting all the words in the file. But how to count words of a certain length?
nCountmethod displays the number of lines in the file, but not the number of words. Only if you have one word in the file in one line.\n- move to a new line. - Denis BubnovnumberOfCharactersand not equality. - Ev_Hyper