Advertisement
coasterka

CurrentWordInASentence

Mar 11th, 2014
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CurrentWordInASentence
  4. {
  5.     class CurrentWordInASentence
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Enter some text: ");
  10.             string text = Console.ReadLine();
  11.             Console.WriteLine("Enter a random word from the text: ");
  12.             string word = Console.ReadLine();
  13.             foreach (string sentence in text.Split('.'))
  14.             {
  15.                 if (sentence.Contains(word))
  16.                 {
  17.                     Console.WriteLine(sentence);
  18.                 }
  19.             }
  20.         }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement