Skip to content

Instantly share code, notes, and snippets.

@richlander
richlander / modernizing-csharp9.md
Last active April 26, 2024 17:14
Modernizing a codebase for C# 9

Modernizing a codebase for C# 9

There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull example requires it.

Use the property pattern to replace IsNullorEmpty

Consider adopting the new property pattern, wherever you use IsNullOrEmpty.

string? hello = "hello world";
.input {
@apply bg-white rounded-lg w-full max-w-lg px-6 border border-gray-300 py-3 mt-2;
&::placeholder {
@apply text-gray-dark;
}
&:focus {
@apply border-opacity-0 outline-none shadow-outline-blue;
}