XML serialization has been around ever since .NET was released since it was so widely used back then. It’s still widely used, especially for legacy applications and services, even iTunes still uses XML to store library information. Benchmark results are for .NET 5 & 6.
A newer way of creating simple methods in .NET is by using expression-bodied methods. This article shows which method is more performant.
Most of the code analysis tools, including tools from Microsoft, recommends creating static methods if possible, stating performance as one of the reasons. But are static methods more performant than normal non-static methods? This articles shows your which is more performant!
Encoding and decoding strings to and from a byte is used a lot in programming. Performance results are for using The formatting options are ASCII, Unicode, UTF8, and UTF32.
When concatenating many strings, especially in a loop, using the StringBuilder class is usually more performant and uses less memory.
This article discusses the performance differences using string.Format() and interpolation.
This article discusses the proper way to check for empty strings in C#.
Let’s discuss for() and foreach() under load to establish a baseline. As you can see below, I used the same code in the previous chapter and added Task.Delay() to simulate a CPU load.
The dotNetDave For Those About To Code: Worldwide Tour will be at the GLUGnet User Group in Okemos, MI on August 19th at 6 PM EDT. I hope you will join me at this meeting. This meeting will be virtual, but I wish it was in person. My session will be followed by a Q&A where you can ask me anything!
The dotNetDave For Those About To Code: Worldwide Tour will be at the Tech Valley .NET User Group (TVUG) in Latham, NY on August 10, 2021.