4. C# — Count Vowels in One Line

using System;

using System.Linq; class Program { static void Main() { string text = "Hello Florida"; // Count vowels int vowelCount = text.Count(c => "aeiouAEIOU".Contains(c)); Console.WriteLine($"Vowels: {vowelCount}"); } }

Cool because:

  • Functional style.

  • Easy to adapt for consonants, digits, etc.

✍️ Written by Luis Fernandez Leyva, Software Engineer

Comments

Popular posts from this blog

About Me

3. C# — Get Unique Characters in One Line

C# — Generate a Random String in One Line