using System; using System.Collections.Generic; using System.Linq; public class Test { static void Main(string[] args) { var strwords = getLastWord("write LINQ queries to do THE following TASK"); foreach (string str in strwords) Console.WriteLine(str); Console.ReadLine(); } static IEnumerable getLastWord(string str) { var upper = str.Split(' ') .Where(s => String.Equals(s, s.ToUpper(), StringComparison.Ordinal)).Reverse().Take(1); return upper; } }