You are developing an ASP.NET MVC application. The application includes the following method. Line
numbers are included for reference only.

The application calls the GenerateMessage method before displaying each page.
The GenerateMessage method throws NullReferenceException exceptions.
You need to use Code Contracts to prevent the exceptions.
Which code segment should you insert at line 03?
Correct Answer: B
Explanation/Reference:
Explanation:
There's "Microsoft Code Contracts" where you use syntax like Contract.Requires(obj != null) which gives
you runtime and compile checking. Contract.Requires specifies a precondition contract for an enclosing
method or property.
Incorrect Answers:
A: Contract.Assume instructs code analysis tools to assume that the specified condition is true, even if it
cannot be statically proven to always be true.
C: Contract.Ensures specifies a postcondition contract for the enclosing method or property.
D: Contract.Invariant specifies an invariant contract for the enclosing method or property, and displays a
message if the condition for the contract fails.
References: https://msdn.microsoft.com/en-us/library/system.diagnostics.contracts.contract
(v=vs.110).aspx