A code snippet illustrating the usage of tuples in C# to return multiple values

Tuples in C#: Too simple or too complex?

Too simple to be a complex type, too complex to be a simple attribute. That鈥檚 what tuples in C# are. Perfect for returning multiple values from a method. No need to create a class (or even a record). Easy to read. Take a look at the image post and see how to use it. Do you use tuples, or do you prefer DTOs/records? 馃憠 Adapted from my original post on LinkedIn . ...

July 20, 2025 路 1 min 路 72 words 路 Eduardo Potumati
An example showing implicit operator conversions in C# with potential pitfalls

Implicit Operators in C#: Convenience vs. Clarity

In C#, implicit operators enable automatic type conversions without the need for explicit casting. This functionality not only enhances code readability but also boosts development agility while safeguarding against runtime conversion exceptions. However, be careful. While implicit conversions offer convenience, excessive usage can potentially compromise code clarity. It鈥檚 essential to tread carefully as an overreliance on implicit conversions may obscure the precise moments and locations where conversions occur. 馃憠 Adapted from my original post on LinkedIn . ...

March 22, 2025 路 1 min 路 77 words 路 Eduardo Potumati
A code comparison showing a foreach loop converted into a LINQ expression

Convert a foreach Loop to LINQ

Convert a foreach loop to LINQ LINQ transforms a query into a first-class language construct in C#. It can reduce the amount of code, enhance readability, and enable similar query expression patterns across different data sources. 馃憠 Adapted from my original post on LinkedIn .

November 15, 2024 路 1 min 路 45 words 路 Eduardo Potumati
Code snippet demonstrating how to compare two numbers using Math.Abs in C#

Comparing Numbers with Tolerance in C#

Comparing Numbers with Tolerance in C# Sometimes, when comparing two numbers in C#, you may want to allow for a tolerance or interval in the comparison. Instead of manually adding, subtracting, and comparing the values, you can use Math.Abs on the difference between the two numbers to check if the result falls within your acceptable range. 馃憠 Adapted from my original post on LinkedIn .

September 15, 2024 路 1 min 路 65 words 路 Eduardo Potumati
Code snippet illustrating data transfer between controllers using TempData

TempData in ASP.NET Core: Transferring Data Between Controllers

TempData - Transfer data between controllers Ideal for transferring small amounts of data between controllers in ASP.NET MVC. Unlike ViewData and ViewBag, which are specific to a single view, TempData persists for one request cycle. This means the data remains available until it鈥檚 accessed, at which point it鈥檚 automatically removed. 馃憠 Adapted from my original post on LinkedIn .

August 15, 2024 路 1 min 路 59 words 路 Eduardo Potumati
Code snippet illustrating the UseRewriter middleware in ASP.NET Core

Handling Duplicate URLs in ASP.NET MVC: www vs non-www

Concerned about duplicate URLs in ASP.NET MVC? Take care of both www and non-www domains. .NET already provides the correct method to handle them. Using the UseRewriter middleware is the optimal approach. You can use AddRedirectToNonWww() or AddRedirectToWww() for this purpose. 馃憠 Adapted from my original post on LinkedIn .

July 15, 2024 路 1 min 路 50 words 路 Eduardo Potumati
Code snippet demonstrating how to use Reflection to read custom attributes in C#

Accessing Custom Attributes Using Reflection in C#

Accessing Custom Attributes Using Reflection in C# Custom attributes provide a powerful way to attach declarative metadata to your code-whether it鈥檚 on classes, methods, properties, or fields. But how do you actually read that metadata at runtime? This is where Reflection shines. By using the System.Reflection, you can dynamically inspect your code鈥檚 structure and retrieve the information defined within those custom attributes. This functionality is the backbone for creating highly flexible applications, such as automated validation frameworks, custom JSON serializers, or dynamic API routing systems. ...

June 15, 2024 路 1 min 路 116 words 路 Eduardo Potumati
Code snippet demonstrating pattern matching to protect against nulls in C#

Pattern Matching in C#: Getting Protected from Nulls

Pattern Matching: Get Protected from Nulls C# pattern matching provides a substantially more concise syntax for testing expressions and taking decisive action when an expression matches. By leveraging these structural features, you can gracefully bundle type checks, variable declarations, and null validations into a single, highly readable statement-significantly reducing boilerplate code and the risk of unexpected NullReferenceExceptions. 馃憠 Adapted from my original post on LinkedIn .

May 15, 2024 路 1 min 路 66 words 路 Eduardo Potumati
Code example illustrating Regex route constraints in ASP.NET Core MVC

Using Regular Expressions for ASP.NET MVC Routing

Using Regular Expressions (Regex) is a highly effective method for segmenting your ASP.NET MVC routing. With Regex route constraints, developers can create intricate matching patterns, leading to much more flexible and dynamic routing configurations directly in their controllers. Important: Always exercise caution when using System.Text.RegularExpressions to process untrusted input, as poorly constructed patterns can be vulnerable to Regular Expression Denial of Service (ReDoS) attacks. 馃憠 Adapted from my original post on LinkedIn . ...

April 15, 2024 路 1 min 路 73 words 路 Eduardo Potumati