Tech Study

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

Introduction

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

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

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

Python Examples

Introduction: Python Examples are the basic programming concepts of python like python syntax,python data types,,python operators,python if else,python comments etc.. …

Read more

C String Functions

C String Functions perform certain operations, It provides many useful string functions which can come into action. The <string.h> header …

Read more