
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
C# program to check for a string that contains all vowels
To check for all vowels, firstly set the condition to check −
string res = str.Where(chk =< "aeiouAEIOU".Contains(chk)).Distinct();
Above, we have used the string −
string str = "the quick brown fox jumps over the lazy dog";
Now, using the Any() method checks whether the string has any vowels or not −
if(!res.Any()) Console.WriteLine("No vowels!");
Loop through the string to get the vowels −
Example
using System; using System.Linq; public class Program { public static void Main() { string str = "the quick brown fox jumps over the lazy dog"; var res = str.Where(chk =< "aeiouAEIOU".Contains(chk)).Distinct(); if(!res.Any()) Console.WriteLine("No vowels!"); foreach(var vowel in res) Console.WriteLine("Your phrase contains vowel = {0}", vowel); } }
Output
Your phrase contains vowel = e Your phrase contains vowel = u Your phrase contains vowel = i Your phrase contains vowel = o Your phrase contains vowel = a
- Related Articles
- Python program to check if a string contains all unique characters
- Java Program to count all vowels in a string
- Python program to accept the strings which contains all vowels
- C# Program to count vowels in a string
- Replace All Consonants with Nearest Vowels In a String using C++ program
- C# program to check if a string contains any special character
- Program to check if a string contains any special character in C
- Java Program to Check if a string contains a substring
- Golang program to check if a string contains a substring
- C++ Program to count Vowels in a string using Pointer?
- Check if a binary string contains all permutations of length k in C++
- Check If a String Contains All Binary Codes of Size K in C++
- C# program to check for URL in a String
- Check if a string contains a sub-string in C++
- To count Vowels in a string using Pointer in C++ Program

Advertisements