C# – Use Convert.ChangeType to convert string to any type

You can use Convert.ChangeType() to convert from a string to any type, like this: Normally you’d call the specific type converter method, like Convert.ToBoolean(“true”). However, sometimes it makes sense to use the generalized type converter method – Convert.ChangeType() – instead of hardcoding the calls to specific type converter methods. I’ll show an example of when … Read more C# – Use Convert.ChangeType to convert string to any type

C# – Generic Plugin Loader

This article explains how to create a generic plugin loader that solves many real world problems when loading plugins in .NET. Besides being generic, this plugin loader also solves the following real world problems when working with plugins: Loads assemblies that have dependencies. Load assemblies that have unmanaged dependencies (like C++ DLLs). Solves the “IsAssignableFrom … Read more C# – Generic Plugin Loader

Multithreaded quicksort in C#

One day I decided to challenge myself by trying to implement multithreaded quicksort. I wanted to see how it would compare to the built-in sort function – Array.Sort(). I came up with two algorithms that were 2-4x faster than Array.Sort(): Top-down: divide-fork-sort-merge Bottom-up: quicksort with fork-on-recursion After continuing to tinker, in attempts to further optimize, … Read more Multithreaded quicksort in C#