title: C#: Force Checking For null With Compiler
body: <p>I am designing an API, and some of the methods return null when they cannot complete the requested operation, like searching for an object by name. This requires all usage of these methods to check for null results, or risk exposing a bug.</p>
  
  <p>Is there anyway to have a Compile-Time error/warning if the result from a method is not checked for null? For example, if you declare a variable and then use it without assigning anything, the compiler complains. The methods return Reference Types and so Nullable would not work, although it does have the behavior I want.</p>
  
  <p>Throwing an Exception would also be a good solution, but as far as I know C# does not have a way to force catching an exception like Java.</p>
  
  <p>Thank you.</p>