MDFT Academy/Write High Performance C# Code

  • €95

Write High Performance C# Code

This course will teach you how to speed up your C# code with performance tricks that every professional developer should know. You’ll learn the fundamentals of the .NET Framework, the Garbage Collector, the stack and heap, boxing and unboxing, and much more. I’ll also give you a crash course in Intermediate Language so that you can read the machine language produced by the C# compiler.

Here's What You'll Get

45

Lessons

45

Videos

10

Quizzes

13

C# Optimizations

This course will teach you how to speed up your C# code with performance tricks that every professional developer should know.

You’ll learn the fundamentals of the .NET Framework, how the Garbage Collector works, the difference between the stack and the heap, what boxing and unboxing is, and much more!

We’ll also look at array performance, using pointers in C# to manipulate memory directly, and a neat trick to place an array in stack memory for extra performance. 

Throughout the course we will be compiling C# code snippets into Intermediate Language, and then inspecting the compiled code for performance bottlenecks. You’ll learn how to interpret basic IL instructions and read machine code directly.

The training covers the following topics:

The Stack

The Heap

Value Types

Reference Types

Boxing

Unboxing

Immutable Strings

Common Intermediate Language

The LDC Instruction

The LDLOC Instruction

The ADD Instruction

The STLOC Instruction

The LDELEM/STELEM Instructions

Other Common IL Instructions

Analyzing Compiled C# Code

Preventing Boxing and Unboxing

String versus StringBuilder Types

Collection Class Performance

Compiled 1-Dimensional Arrays

Compiled 2-Dimensional Arrays

Compiled Jagged Arrays

The Exception Overhead

For versus ForEach Performance

The Garbage Collector

Generation 0, 1 and 2 Heaps

The Large Object Heap

Optimizing for Generation 0

Optimizing for Object Size

Optimizing for Object Lifetime

Unicast Delegate Performance

Multicast Delegate Performance

Dynamic Instantiation Performance

Dynamic Method Delegate Performance

Allocate Arrays on the Stack

Pointers in C#

Fixing Heap Memory

Referencing a Pointer

Dereferencing a Pointer

Incrementing a Pointer

Optimizing C# code with Pointers

Lesson Preview

Check out this lesson preview in which I will show you how the C# compiler treats 1-dimensional, multidimensional and jagged arrays differently. Find out which array type performs best.

The video covers Arrays and Intermediate Language.

Featured C# Optimizations

Here are four C# code optimization slides from the training. You can apply these optimizations to C# code to obtain the best possible performance.

Boxing and Unboxing

Understand the boxing operation so that you can avoid it in mission-critical code

String Manipulation

Learn how to efficiently manipulate strings in C# without breaking the heap

Garbage Collection

Understand how the Garbage Collector works, so you can use it to your advantage

Pointers

Learn how to use pointers in C# to access and manipulate heap memory directly

Try The Labs

Would you like a sneak peek at the labs in this course? These blog articles address specific performance optimizations and are based on actual lab assignments in this training courses.

What You'll Need

For this course you will need a computer (running Windows, MacOS, or Linux), Microsoft Visual Studio Code, and the NET Core SDK.

Buy This Course

Choose the plan that works best for you. Buy this course and dive into C# performance optimization, or unlock unlimited access to every course on the site.

Want the best learning experience?
Members get access to the full course library, all labs and community pages, receive priority support and sneak previews of future course releases.

Prices shown exclude VAT. EU businesses can defer VAT during checkout with a valid VAT ID number.

Buy This Course

Buy this course and get lifetime access to all lectures and knowledge quizzes

✔️ This course
✔️ Included quizzes only
✔️ Included labs only
🚫 No priority support
🚫 No community access
🚫 No future courses

€95 one time

Get A Membership

Get access to all courses, lectures, labs, quizzes, and future releases

✔️ All courses
✔️ All quizzes
✔️ All labs
✔️ Priority support
✔️ Community pages
✔️ Access to future courses

€35 p/mo or €350 p/yr

Team Training

In-company or online team training with guided labs and live support

🪙 Onsite or online
🪙 Conducted live
🪙 For teams of 5-12
🪙 3-day training
🪙 Guided labs
🪙 Can be customized

€1250 p/day

Training Curriculum

Introduction

Course introduction
Introduction to code optimization
Windows, OS/X or Linux?

Fundamentals of the .NET Framework

Section introduction
Quiz 1: The Stack
The Stack
Preview
Quiz 2: The Heap
The Heap
Preview
Value types
Value types
Preview
Reference types
Reference types
Preview
Boxing and unboxing
Boxing and unboxing
Immutable strings
Immutable strings
Section recap

A crash course in Intermediate Language

Section introduction
Common Intermediate Language
Section recap
Common Intermediate Language

Basic optimizations: the low-hanging fruit

Section introduction
How to prevent boxing and unboxing
Fast string concatenation
Fast collections
Fast arrays
Throwing and catching exceptions
For versus Foreach
Section Recap
Basic optimizations

Intermediate optimizations

Section introduction
Fast Garbage Collection - part 1
Fast Garbage Collection - part 2
Fast delegates
Fast class factories
Section recap
Intermediate optimizations

Advanced optimizations

Section introduction
Arrays on the stack
Pointers - part 1
Pointers - part 2
Background Info - Modifying String Constants
Section recap
Advanced optimizations

Final words

Course recap

What My Students Are Saying

As a Unity developer and C# coder, this course was perfect for me. It is a fantastic course and an eye opener. Thanks to this course, I have seen a great improvement in my game development by implementing the knowledge I discovered.

Scott Tozer

A great course to learn some of the speed enhancements within the .NET framework. The content is straightforward to follow and also goes into great depth. The speed test examples and details of the CIL code were enlightening.

Mark Baker

Still Got Questions?

I hope I've given you a clear overview of the contents of this training course. But if anything is still unclear and you have some unanswered questions, then please check out this FAQ section

What is an online training?

In an online training you can study the training lectures and work on the homework assignments in your own time and at your own pace. You can spend as many or as little hours per week as you want on the training.

What's included?

You will receive prerecorded online video lectures, text lectures, multiple-choice quizzes and homework exercises.

How am I supported?

You are supported through email, and you can also book a 30-minute video support call with me if you want. I will help you with the training lectures and homework projects and get you ready for your certification exams.

Who should attend?

An online training is ideal for tech professionals who want to set their own learning pace and prefer to work independently with a bit of guidance and support throughout the training.

Where is the training hosted?

I host all my training content on Podia, a well-known e-learning platform based in the United States.

How long do I have access?

You have unlimited access to the online training content and your login account will never expire.

Can you train my entire team?

Yes! I often host classroom trainings where I teach tech subjects to an entire business team. Contact me and we'll get it organised.

See Me In Action

C# PERFORMANCE TRAINING FOR THE DUTCH ARMED FORCES IN AMERSFOORT

In 2022 I gave a C# Performance training for the Dutch armed forces who are using .NET code in some of the embedded systems of their artillery vehicles. In a 3-day training I showed military software developers how to optimize the performance of C# code running on a restricted hardware platform.

Unfortunately I wasn’t allowed to take pictures of the team or the barracks, so all I can show you is a photo of this very cool old tank that was parked next to the army museum.

Would You Like To Know More?

Sign up for the newsletter and get notified when I publish new posts and articles online.
Let's stay in touch!

You're signing up to receive emails from MDFT Academy