Advertisement
Stann

LongestWordInText

Apr 13th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class LongestWordInText
  4. {
  5.     static void Main()
  6.     {
  7.         //Write a program to find the longest word in a text.
  8.  
  9.         string input = Console.ReadLine();
  10.         string[] words = input.Split(new char[] { ' ','.',',',';',':','-','?','!'}, StringSplitOptions.RemoveEmptyEntries);
  11.         string longest = words.OrderByDescending( s => s.Length ).First();
  12.         Console.WriteLine(longest);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement