Advertisement
gardax

LongestWordInText

Apr 9th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _14_LongestWordInText
  5. {
  6.     class LongestWordInText
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string text = Console.ReadLine();
  11.  
  12.             string[] words = text.Split(new char[] {' ', '.', ',', '!', '"', }, StringSplitOptions.RemoveEmptyEntries);
  13.             string longestWord=words.OrderByDescending(s => s.Length).First();
  14.             Console.WriteLine(longestWord);
  15.  
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement