title: In C#, should one check references passed to methods against null?
body: <p>Well, a few months ago I asked <a href="https://stackoverflow.com/questions/4390007/in-either-c-or-c-should-i-check-pointer-parameters-for-null">a similar question about C and C++</a>, but I've been paying more attention to C# lately due to the whole "Windows Phone" thing.</p>
  
  <p>So, in C#, should one bother to check against NULL at method boundaries? I think this is different than in C and C++, because in C# one generally can determine whether a given reference is valid -- the compiler will prevent one from passing uninitialized references anywhere, and therefore the only remaining possible mistake is for it to be null. Furthermore, there's a specific exception defined inside the .NET Framework for these things, the <a href="http://msdn.microsoft.com/en-us/library/system.argumentnullexception.aspx" rel="nofollow noreferrer">ArgumentNullException</a>, which seems to codify what programmers think they should be getting when an invalid null was passed.</p>
  
  <p>My personal opinion is once again that a caller doing this is broken, and that said caller should have NREs thrown at them until the end of days. However, I'm much less sure about this than I am in native code land -- C# has quite a different programming style in places compared to either C or C++ in this regard.</p>
  
  <p>So... should you check for null parameters in C# methods?</p>