
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C# program to check if string is panagram or not
A pangram has all the 26 letters of an alphabet.
Below, we have entered a string, and will check whether it is a pangram or not −
string str = "The quick brown fox jumps over the lazy dog";
Now, check using the ToLower(), isLetter() and Count() functions that the string has all the 26 letters of not since pangram has all the 26 letters of an alphabet.
Example
You can try to run the following code to check whether a string is pangram or not.
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
- Related Questions & Answers
- C# program to check if a string is palindrome or not
- C program to check if a given string is Keyword or not?
- Python program to check if a string is palindrome or not
- Java Program to check if a string is empty or not
- Python program to check if the string is empty or not
- C Program to check if matrix is singular or not
- C++ Program to check string is strictly alphabetical or not
- Python program to check if a given string is Keyword or not
- C# Program to check if a number is prime or not
- C Program to check if a date is valid or not
- C Program to check if an Array is Palindrome or not
- C++ program to check whether given string is bad or not
- Python - Check if a given string is binary string or not
- Recursive program to check if number is palindrome or not in C++
- C++ code to check string is diverse or not
Advertisements