Posts

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

3. C# — Get Unique Characters in One Line

Want only distinct characters from a string? using System; using System.Linq; class Program { static void Main () { string text = "Mississippi" ; // Unique characters string unique = new string (text.Distinct().ToArray()); Console.WriteLine(unique); // Misp } } ✅ Cool because: Uses LINQ’s Distinct() . Cleans up duplicates instantly. ✍️ Written by Luis Fernandez Leyva , Software Engineer

2. C# — Check Palindrome in One Line

Is a string the same forwards and backwards? Try this: using System; using System.Linq; class Program { static void Main () { string word = "level" ; // Palindrome check bool isPalindrome = word.SequenceEqual(word.Reverse()); Console.WriteLine(isPalindrome); // True } } ✅ Cool because: No loops. Works for numbers too ( 12321.ToString() ). ✍️ Written by Luis Fernandez Leyva , Software Engineer

C# — Shuffle a String in One Line

  Need to randomly shuffle the characters of a string? Most people would loop and swap, but here’s a LINQ one-liner: using System; using System.Linq; class Program { static void Main () { string text = "HELLOWORLD" ; // Shuffle the string in one line string shuffled = new string (text.OrderBy(_ => Guid.NewGuid()).ToArray()); Console.WriteLine( $"Shuffled: {shuffled} "); } } ✅ What’s cool about it? Uses OrderBy with Guid.NewGuid() for randomness. No loops or manual swaps needed. Works with any string—names, codes, even emojis. 🧩 Curiosity twist: Shuffle words instead of characters! string sentence = "C# makes coding fun and expressive" ; string shuffledWords = string .Join( " " , sentence.Split( ' ' ).OrderBy(_ => Guid.NewGuid()) ); Console.WriteLine(shuffledWords); Example output: expressive coding and C# fun makes ✍️ Written by Luis Fernande...

5 Curious C# Tricks You Might Not Know

 As developers, we often use C# in very structured and predictable ways. But sometimes the language has neat shortcuts and hidden gems that can make even simple tasks more elegant (or just more fun!). In this post, I’ll share a handful of curious C# tricks —small snippets that do something simple but in a unique way. These are not necessarily for production code (though some are handy!), but they’ll make you see C# a little differently. 1. Reverse a String with LINQ Most people use loops or Array.Reverse —but here’s a LINQ way: string text = "Hello World" ; string reversed = new string (text.Reverse().ToArray()); Console.WriteLine(reversed); // dlroW olleH ✨ Why it’s cool: clean, expressive, and just one line. 2. Swap Two Numbers Without a Temp Variable Old school swaps usually need a temporary variable, but C# tuples make it elegant: int a = 5 , b = 10 ; (a, b) = (b, a); Console.WriteLine( $"a = {a} , b = {b} "); // a = 10, b = 5 ✨ Why it’s cool:...

C# — Generate a Random String in One Line

  C# — Generate a Random String in One Line Most people use loops to build random strings, but here’s a fun way with LINQ : using System; using System.Linq; class Program {     static void Main()     {         // Generate a random 12-character string (letters + digits) in one line         string randomCode = new string(             Enumerable.Range(0, 12)                       .Select(_ => "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[new Random().Next(36)])                       .ToArray()         );         Console.WriteLine($"Your unique code: {randomCode}");     } } ✅ What’s cool about it? Uses LINQ and Enumerable.Range instead of loops. Builds the string in a functional style . The source alphabet can be changed to includ...

About Me

Image
Hi! 👋 My name is Luis Fernandez Leyva , and I’m a Software Engineer who loves turning complex ideas into simple, working solutions. I spend most of my time designing and building applications with .NET, C#, SQL Server, Blazor, Angular, and Azure —always looking for ways to make software faster, smarter, and easier to use. On this blog, I share insights, tutorials, and lessons learned from real projects. Whether it’s performance optimization, clean architecture, cloud solutions, or automation , my goal is to make technology approachable and practical for developers at all levels. What I Do Build scalable apps with .NET Core / .NET 8 Explore cloud solutions with Azure Write about databases, APIs, and DevOps pipelines Share personal experiments in AI, SEO tools, and automation Beyond Code When I’m not coding, you’ll probably find me in the kitchen cooking . For me, cooking is another form of creativity—it’s about experimenting, adjusting, and improving, just like writi...