Skip to main content
3 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/

Enforcement of returning non-null

We are implementing some web services, and need to ensure that some of our methods always return non-null values.

We've investigated two ways of doing this:

Both approaches work, but I'm wondering whether there are any other approaches that we should consider.

How would you enforce non-null return values?


Looks like there was a similar question on SO, and Jon Skeet recommends the Code Contract approach.

Peter K.
  • 3.8k
  • 1
  • 27
  • 35