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

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?

8 Answers
8

Leave a Comment