Skip to content

Commit 0111485

Browse files
committed
vowel counter minimized code
1 parent a7a38fe commit 0111485

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

vowel_counter_minimized.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
using System;
3+
using System.Linq;
4+
5+
class VowelCounterMinimizedClass
6+
{
7+
// Program's Entry-Point method
8+
static void Main()
9+
{
10+
// Source-code contains minimized number of statements/lines
11+
// making use of built-in delegate Func,
12+
// and Lambda expression instead of named methods
13+
Console.Write("Enter Any Text: ");
14+
Func<string, string> VowelCounterFuncDelegate = txt => txt.ToLower().Aggregate("", (ac, c) => ac += "aeiou".Contains(c) ? c : "", ac => $"'{txt}' contains {ac.Length} Vowels ({ac}).");
15+
Console.WriteLine(VowelCounterFuncDelegate(Console.ReadLine()));
16+
}
17+
}

vowel_counter_minimized.csproj

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
6+
</PropertyGroup>
7+
<ItemGroup>
8+
<Compile Include="vowel_counter_minimized.cs" />
9+
</ItemGroup>
10+
</Project>

0 commit comments

Comments
 (0)