How To Write Very Fast C# Code

I presented this webinar in 2017 for Postsharp, a company that has developed a very cool toolkit that allows you to write aspect-based C# code.

In the webinar you’ll see several techniques to write very fast C# code. I will demo code to speed up exceptions, string handling, array manipulation, loops, structs, memory copying, and instantiating and accessing objects.

1 Hour

English

Intermediate

Webinar Contents

Throwing Exceptions

The exception overhead

Parsing corrupted data

Benchmark: Parse vs TryParse

Fast String Handling

Working with String

Working with StringBuilder

Working with char pointers

Benchmark: String vs StringBuilder

Benchmark: StringBuilder vs Char*

Fast Array Handling

Single and Multidimensional arrays

Fast array indexing

Benchmark: 3 vs 1-dimensional arrays

The LDELEMA IL instruction

Fast Loops

The Enumerator overhead

Benchmark: for vs foreach

Inspecting the compiled IL code

Structs versus Classes

Structs and classes in C#

Benchmark: struct vs class

Stack and heap memory

The impact of adding a finalizer

Fast Memory Copy

Byte arrays and byte pointers

Benchmark: byte[] vs byte*

The CopyTo() method

Bemchmark: byte* vs CopyTo

Fast Object Instantiation

Using Activator.CreateInstance

Using dynamic IL injection

Benchmark: reflection vs dynamic IL

Fast Property Access

Using reflection 

Using dynamic IL injection

Benchmark: reflection vs dynamic IL

Watch The Webinar

Ready For More?

CHECK OUT MY C# TRAINING COURSES

Did I pique your interest? Then check out all of my C# training courses and get ready to supercharge your software development career today. See anything that you like?

Download The Source Code

Would you like to experiment with your own code? Just click the button to download the exact same source code that I use in the webinar. Use my code as a starting point to develop your own benchmarks and dramatically speed up your C# apps!

Testimonials

what my students are saying about ME