Blazor – first impressions

What is Blazor? To quote the official Blazor homepage ”Blazor is a single-page web app framework built on .NET that runs in the browser with WebAssembly.” The natural follow-up question is then ”What is WebAssembly?”. From the official WebAssembly homepage we can read that ”WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based […]

How to design a Priority Queue in C#

What is a Priority Queue? To be a bit formal, a priority queue is an abstract data type (ADT), similar to a regular queue, but where each element has a priority associated to it. An element with high priority is served before an element with a low priority. Elements which have the same priority are […]

C# Pitfalls of returning IEnumerable

Generic and specific return types It is often preferred to work with as generic types as possible. Doing that opens up for more flexibility and being able to modify parts of the code without effecting any other parts. One example of this is IEnumerable<T> which is implemented by several generic collection types, such as HashSet<T>, […]

Building strings in C# with good performance

A little bit on strings Strings in C# are immutable. What that means is that you cannot modify an existing string, you must create a new one. Also strings are objects – sequential read only collections of char objects – so they are allocated on the managed heap, and therefore managed by the Garbage Collector […]