# Number of times a word appears in the region statistics file. While (true) {console. writeline ("Enter the words to query:"); string word = console. readline (); string [] novelarr = file. readalllines ("xiyou.txt", encoding. default); int COUNT = 0; // count variable int Index = 0; // The initial index of each row for (INT I = 0; I <novelarr. length; I ++) {Index = 0; // After traversing a row, return to If (novelarr [I]. length = 0) // if the current behavior is null, The continue is displayed. While (Index = novelarr [I]. indexof (word, index ))! =-1) {// each row starts from index 0. Assign the first index to the current index, that is, skip the searched count ++; index ++ = word. length; // skip the length of the characters} console. writeline ("{0} appears {1} Times. ", Word, count) ;}# endregion
Specific word count (index)