In C#, what happens when you call an extension method on a null object?

Posted by tpower on Stack Overflow See other posts from Stack Overflow or by tpower
Published on 2009-05-11T08:35:27Z Indexed on 2010/05/20 20:10 UTC
Read the original article Hit count: 155

Filed under:
|
|
|

Does the method get called with a null value or does it give a null reference exception?

MyObject myObject = null;
myObject.MyExtensionMethod(); // <-- is this a null reference exception?

If this is the case I will never need to check my 'this' parameter for null?

© Stack Overflow or respective owner

Related posts about extension-methods

Related posts about c#