C# Performance Optimization

Learn how to write high-performance C# code.

A couple of years ago I was living and working in Belgium. I joined a small team of SharePoint specialists to build a custom application for a financial institution in Brussels. We were writing a lot of hand-coded C#.

I worked with a colleague who was fresh out of college with a computer science education under his belt. But I noticed something very interesting: even though he could write perfectly functional C# code, nobody had ever taught him how to write fast and efficient code.

Here's an example. Take a look at these two code snippets:

Which code snippet do you think is the fastest?

Now, to be fair, my colleague had heard of a StringBuilder. But nobody had ever explained to him why it exists, so he didn’t realize when he should use it.

Seasoned C# developers will know that the code on the left is extremely inefficient for large loops because in C# strings are optimized for comparing, not for modifying. The heap will be littered with out-of-scope copies of the string. We're supposed to use the StringBuilder class here, because it is optimized for modifying.

But let’s face it: the NET Framework is huge. For any given problem there are many competing solutions, and it is not always clear which solution is the best choice.

I created this course specifically for people like my colleague: developers who already have a working knowledge of C# programming, but who want to learn how to write fast and efficient code, and gain more understanding of what is going on under the hood of the .NET Framework.

“An eye-opening look under the hood of your code.”

- Mark Miller, course student

In the course, I cover many common performance bottlenecks. I introduce each problem with a small test program to measure the baseline performance. Then I’ll demonstrate a couple of possible solution, and benchmark how each solution measures up.

I also added a section on Common Intermediate Code (CIL), the ‘machine’ language that the C# compiler compiles to. The CIL language is very easy to read and understand, I cover all the basics in a short 15-minute lecture.

Being able to read CIL code is an extremely useful skill that will help you analyze the output of the C# compiler, and help you avoid many performance pitfalls of the NET Framework.

Class Curriculum

  Final Words
Available in days
days after you enroll

Frequently Asked Questions

When does the course start and finish?
The course starts when you enroll and never ends. It is a self-paced online course, so you decide when you start and when you finish.
How long will I have access to the course?
That depends. If you take a subscription you'll have access to everything for as long as your subscription is active. If you purchase the course you'll have lifetime access, but only to this course.
What if I want a refund?
I'm happy to issue a full refund within the first 30 days.
What skills will this course teach me?
This course will teach you how to write fast and efficient C# code. You'll learn compiled CIL code, efficient use of pointers, how to optimize for the Garbage Collector, and much more!
Will this course help me grow in my career?
Yes! I created this course to teach developers the exact kind of skills I want to see in the people I work with.
What equipment/tools will I need to complete the course?
A computer with the .NET Framework installed, and your favourite IDE (I use Visual Studio Community Edition for OS/X)
Will I get access to the full course all at once?
Yes. You can go through the curriculum in any order you like.
Where is this course hosted?
This course is hosted on Teachable, a well-known and respected educational technology company. Teachable provides a social online learning platform and is based in New York.
What do I do if I need help?
If you need help with something related to the course, please contact me at mark@mdfarragher.com. Thanks!

Get started now!


Subscribe to all of my courses, and get automatic access to any new course I produce for only $19 / month. More...