public static void PrintWordsInSentence(this SentenceUnit Sentence) { if ((Sentence != null) && (Sentence.Words.Count > 0)) { Console.ForegroundColor = ConsoleColor.White; Console.Write("Words:"); Console.ForegroundColor = ConsoleColor.Cyan; foreach (WordUnit item in Sentence.Words) { Console.Write('|' + item.Text); } Console.Write('|'); } }
public string ReplaceSentenceWordsBySubStr(SentenceUnit Sentence, int WordLength, string SubStr) { if ((Sentence != null) && (Sentence.Words.Count >= 1)) { string text = Sentence.Sentence; foreach (WordUnit Word in Sentence.Words) { if (Word.Length == WordLength) { text = text.Replace(Word.Text, SubStr); } } return(text); } else { return(""); } }