On June 15th I gave this 1-hour webinar about C# Performance Optimization. The webinar was hosted by Postsharp, creators of the Visual Studio extension of the same name.
If you are a tech leader, writing high-performance C# code is a very important skill for you to master. It will help you and your team create scalable code that can take a beating.
In this webinar, I go through several performance optimization tricks for C# code. I start with a demonstration of the overhead of throwing exceptions, I show the difference between using a string and a StringBuilder, and I compare 1- and 2-dimensional array performance. Then I take a closer look at for- and foreach-loops, and wrap up with a very fast class factory and some highly optimized reflection code.
I use advanced techniques in my code, including pointer operations that write directly into heap memory, and a custom dynamic method that I build out of individual CIL instructions. At several points in the webinar, I’ll show you the CIL code produced by the C# compiler and point out specific code fragments that improve or impair performance.
Also published on Medium.