C# Tip: Initialize lists size to improve performance
Lists have an inner capacity. Every time you add more items than the current Capacity, you add performance overhead. How to prevent it?
Lists have an inner capacity. Every time you add more items than the current Capacity, you add performance overhead. How to prevent it?
By using list patterns on an array or a list you can check whether a it contains the values you expect in a specific position.
In C#, nameof can be quite useful. But it has some drawbacks, if used the wrong way.
If you need a sequence of numbers, you can pick two ways: use a While loop, or use Enumerable.Range
When you need to fire synchronous events, don't use a while(true) loop: use a Timer!
C#, as every other language, has several reserved keywords. Did you know that you can use them if you use the `@` prefix?
Miniprofiler is a nice tool to profile your code in a smart way.
SelectMany is one of the LINQ methods I've used the least. I couldn't get it! Turns out it was actually incredibly simple.
Initializing HttpClient instances can expose you to Socket Exhaustion problems. You should use IHttpClientFactory instead
How to get all the keys of an ExpandoObject? Convert it to Dictionary!
It would be great if we could break the debugging flow if a condition is (not) met. Can we? Of course!
What can you do if you need to temporarily change the CurrentCulture in C#?
Instead of using if-else or switch blocks to handle exceptions, you can do it gracefully using the 'when' keyword.
Yield is a keyword that allows you to return an item at the time instead of creating a full list and returning it as a whole.
Using the right data structure is crucial to building robust and efficient applications. So, why use a List or a HashSet to sort items (and remove duplicates) when you have a SortedSet?
Sometimes you need to ping some endpoints. Don't rely on HttpClient, but use the native Ping class.
Sometimes we need to use objects with the same name but from different namespaces. How to remove that ambiguity? By Using Aliases!
Creating simple DateTimes creates issues when handling timezones. You can solve some issues by using DateTimeKind
Is your string really empty, or has it hidden characters? With String.IsNullOrEmpty and String.IsNullOrWhiteSpace you can find it
Do you need the index of the current item in a foreach loop with C#? Here you'll see two approaches.