Skip to main content

.NET Tips

A category with .NET tips and tricks. All posts in this category are shorts and will only focus on something very specific. You will not find long in-depth tutorials here, but I promise to link to all related articles in the shorts, so you can explore on your own.

A collection of 8 posts

Use JsonSerializer to Pretty-Print JSON in .NET
.NET Tips

Use JsonSerializer to Pretty-Print JSON in .NET

Formatting JSON as plain text with proper indentation can make it much easier to include in emails or other readable contexts. Here's a quick tip/guide on how to achieve that in .NET.

· Christian Schou Køster

.net, nameof, c#, refactoring
.NET Tips

Use nameof to Keep Code Refactoring-Safe

Using nameof in .NET helps make code more maintainable and resilient to refactoring. It returns names as strings tied to code directly, improving readability, refactoring safety, and compile-time error checking.

· Christian Schou Køster

Enhance String Semantics with the StringSyntax Attribute
.NET Tips

Enhance String Semantics with the StringSyntax Attribute

Learn how to use the StringSyntax attribute in .NET to clarify string formats like DateTime, JSON, or Regex, enhancing readability, IDE support, and reducing errors when writing .NET or C# code ✌️

· Christian Schou Køster

base64, url encoding, dotnet 9, base64 encoding, .net base64 encoding
.NET Tips

URL-Safe Base64 Encoding With .NET 9

.NET 9 introduces a new Base64Url type for URL-safe Base64 encoding, solving the issue of unsafe characters like /, +, and =.

· Christian Schou Køster

null conditional operator, conditions, csharp
.NET Tips

Replace IF-Statements With Null Conditional Operators

Ever heard of the null conditional operator (?.) in C#? It helps make your code cleaner by safely accessing members or methods that might be null, returning null instead of throwing exceptions. A handy feature from C# 6.0! ✌️

· Christian Schou Køster

Do You Know About The File Access Modifier In C#?
.NET Tips

Do You Know About The File Access Modifier In C#?

The file access modifier in C# is like keeping your tools in the right drawer—everything stays organized, and nothing gets mixed up where it doesn’t belong!

· Christian Schou Køster

Why You Shouldn't Concatenate Strings Using "+" In Loops
.NET Tips

Why You Shouldn't Concatenate Strings Using "+" In Loops

Strings should not be concatenated using "+" in a loop. Learn what to do instead in this .NET tip. 💡

· Christian Schou Køster

keyset pagination
.NET Tips

What Is Keyset Pagination?

Keyset Pagination is also known as cursor pagination and is currently one of the fastest pagination techniques in .NET 🔥

· Christian Schou Køster