C# program to check if a string is a full word

王林
Release: 2023-08-30 22:09:07
forward
500 people have browsed it

C# 程序检查字符串是否为全字词

Full Grammar contains all 26 letters of the alphabet.

Below, we input a string and will check if it is full syntax. -

string str = "The quick brown fox jumps over the lazy dog";
Copy after login

Now, use ToLower(), isLetter() and Count() functions to check if the string contains all 26 letters of not because pangram contains all 26 letters of the alphabet.

< h2 >Example

You can try running the following code to check if the string is a pangram.

Live Demo< /p>

using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Demo { public class Program { public static void Main(string []arg) { string str = "The quick brown fox jumps over the lazy dog"; Console.WriteLine("{0}: \"{1}\" is pangram", checkPangram(str), str); Console.ReadKey(); } static bool checkPangram(string str) { return str.ToLower().Where(ch => Char.IsLetter(ch)).GroupBy(ch => ch).Count() == 26; } } }
Copy after login

Output

True: "The quick brown fox jumps over the lazy dog" is pangram
Copy after login

The above is the detailed content of C# program to check if a string is a full word. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!