Q:

Write a program in C# to find the uppercase words in a string in LINQ Query

belongs to collection: All LINQ programs in C# with examples

0

Write a program in C# to find the uppercase words in a string in LINQ Query

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
using System.Linq;
using System.Collections.Generic;
 
class LinqExercise
{
    static void Main(string[] args)
    {
        string str;
        Console.Write("Input the string : ");
        str = Console.ReadLine();
 
        var ucWord = WordFilt(str);
        Console.Write("\nThe upper case words are :\n ");
        foreach (string strRet in ucWord)
        {
            Console.WriteLine(strRet);
        }
        Console.ReadLine();
    }
 
    static IEnumerable<string> WordFilt(string mystr)
    {
        var upWord = mystr.Split(' ')
                    .Where(x => String.Equals(x, x.ToUpper(),
                    StringComparison.Ordinal));
 
        return upWord;
 
    }
}

Result:

Input the string : TechStudy - the COMPLETE debuggin SOLUTION

The upper case words are :

 -

COMPLETE

SOLUTION

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a program in C# to Remove Items from List us... >>
<< Write a program in C# to display the characters an...