Impossible to use ref and out for first ("this") parameter in Extension methods?

Posted by Hun1Ahpu on Stack Overflow See other posts from Stack Overflow or by Hun1Ahpu
Published on 2010-04-11T20:31:11Z Indexed on 2010/04/11 20:53 UTC
Read the original article Hit count: 231

Filed under:
|

Why is it forbidden to call Extension method with ref modifier?

This one is possible:

public static void Change(ref TestClass testClass, TestClass testClass2)
    {
        testClass = testClass2;
    }

And this one not:

public static void ChangeWithExtensionMethod(this ref TestClass testClass, TestClass testClass2)
    {
        testClass = testClass2;
    }

But why?

© Stack Overflow or respective owner

Related posts about c#

Related posts about extension-methods