• Fun with pointers in C#

    Monday, July 19, 2010 by Just* Team | Go comment!

    Disclaimer: this post is all about fun. It is not about:

    •   turning a bug into a feature
    •   some new isolation/mocking practice
    •   wow, look what I will do with pointers in my next project

    It is all about fun :) It shows some of CLR internals as well.

    As far as I know since .NET 2.0 there is a bug in Microsoft C# compiler that makes it possible to compile the following source code.

    class Class1
    {
        unsafe public static void Method1(ref object* obj) {}
    }

    Trying to compile it with .NET 1.1 Microsoft C# compiler produces an error:

    error CS1005: Indirection to managed type is not valid

    In my job I have...