I generally don’t like too much ‘sugar’ being added to C# but Switch Expressions from C# 8 really can improve readability a lot …
Are you using switch expressions in your apps?
Example below is courtesy of ChatGPT 😉 …
You might also be interested in...
Favour Boolean assignment via expressions in C# rather than if/else blocksWhere applicable favour Boolean assignment via expressions rather than if/else blocks. The first example below is still so common but … Continue reading Favour Boolean assignment via expressions in C#...
Use the digit separator character in C# to improve readability of large numbers
Using the digit separator character _ in C# to break up your large numbers is just another little thing you … Continue reading Use the digit separator character in C#...
Entity Framework Core 7.0 will not wrap single changes in a transaction where possible to improve performance
Entity Framework Core 7.0 will not wrap single changes in a transaction where possible to improve performance. This is nice … Continue reading Entity Framework Core 7.0 will not wrap...
Consider using named arguments in C# to increase readability of method calls
By using named arguments in C# we don’t have to match the ordering of parameter lists of called methods. Instead the … Continue reading Consider using named arguments in C# to...
Set List<> initial capacity to improve speed
FYI… setting capacity on a List<> when creating it can avoid a lot of expensive resizing operations. Even if we … Continue reading Set List initial capacity to improve speed...