1

Why is throw null not a compiler warning in C#?

I saw some code which had a throw null; in it. This causes a new NullReferenceException to be thrown.

Why would the compiler not flag this with a warning?

Oded
  • 489,969
  • 99
  • 883
  • 1,009
eduesing
  • 351
  • 1
  • 5
  • 2
    Duplicate of [Why does C# let you throw null](http://stackoverflow.com/questions/2195764/why-does-c-sharp-allow-you-to-throw-null) . Related : [in Java](http://stackoverflow.com/questions/6591910/why-throw-null-is-not-creating-compilation-error-in-java) – Benjamin Gruenbaum Jun 21 '13 at 20:39
  • For the same reason that you don't have a warning label on a microwave oven that says it is not suitable to dry the poodle. – Hans Passant Jun 22 '13 at 01:43

0 Answers0