সকল স্বরবর্ণ যাচাই করতে, প্রথমে শর্ত সেট করুন:
var res = str.Where(chk => "aeiouAEIOU".Contains(chk)).Distinct();
উপরে আমরা নিচের স্ট্রিং ব্যবহার করেছি:
string str = "the quick brown fox jumps over the lazy dog";
এখন Any() মেথড ব্যবহার করে যাচাই করুন স্ট্রিং-এ কোনো স্বরবর্ণ আছে কিনা:
if (!res.Any())
Console.WriteLine("No vowels!");
স্ট্রিং-এর মাধ্যমে লুপ চালিয়ে স্বরবর্ণগুলো পান:
সম্পূর্ণ উদাহরণ
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);
}
}
আউটপুট
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