sizeof() vs Marshal.SizeOf()

To get the size of a data type in .Net you can use   or  . I’ll briefly explain the difference between the two. sizeof()   (MSDN) can only be used on data types that have a known size at compile-time. It is compiled as a constant. If you attempt to use it on invalid … Read more

Cost of method wrapper

Introduction What happens if a method is just a wrapper for another method? Is the extra jump optimized away by compiler? Does it take much time? I thought I’d look into this and measure a bit. With the different compilers, Jits and runtimes I thought it would be fun to see what happens. I’ll use … Read more

Speeding up Unitys Vector in lists/dictionaries

Introduction With this post I am digging into some performance improvements for Unity 3D’s Vector2, Vector3, Vector4 and Quaternion. The short version is that they really need   and can benefit from a better  . I’m demonstrating this with example of how it severely decreased performance in my project. Adding IEquatable<T> has no side-effects, if … Read more

Norske fødselsnummer i C# / Norwegian national ID numbers in C#

Available as NuGet package: https://www.nuget.org/packages/Tedd.Fodselsnummer Code to verify Norwegian national id number (fødselsnummer / personnummer) written in C#. Obeys 2013 standards as described in this Wikipedia article. Please let me know how if you find bugs / improvements. 🙂 (PS: This code is easy to test in LINQPad. Select C# Program, paste it in and hit run.)

ASP.Net 5 Areas

Visual Studio 2015 with ASP.Net 5 doesn’t support Areas in the GUI editor. Hopefully that will come, but until then here is a simple workaround. Create folder structure In the root of your project (not wwwroot) create the folder structure for Areas manually. In this example I created an area named “Foobar”. Edit Startup.cs to … Read more

Better text console for C#

I recently discovered how slow Console.MoveBufferArea actually is. I used it for writing NLog output to a console and discovered that at times of high output it became dead slow. I could at times see it flicker and update line for line while the whole machine temporarily came to a crawl. As I searched the … Read more