Home >Backend Development >C#.Net Tutorial >C# program to check if a string is a full word

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

王林
王林forward
2023-08-30 22:09:07625browse

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";

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.

Example

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

Live Demo

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;
      }
   }
}

Output

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

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete