C# – Remove a set of characters from a string

The fastest and simplest way to remove a set of characters from a string is to use StringBuilder + List<char>, like this: I compared this with three other approaches. I did 100,000 iterations with a string with 2500 characters and a list of 15 characters to remove. This StringBuilder approach is almost 2x faster than … Read more

C# – Convert a list of strings into a set of enums

Let’s say you have a list of HTTP status codes that you read in when the service starts up (perhaps from appsettings.json or from the database). Whenever you send an HTTP request, you want to check if the returned status code is in this list of status code. To make things more efficient, you want … Read more