Apparently the vast majority of errors in code are null reference exceptions. Are there any general techniques to avoid encountering null reference errors?
Unless I
One of the most common null reference errors that I've seen is from strings. There will be a check:
if(stringValue == "") {}
But, the string is really null. It should be:
if(string.IsNullOrEmpty(stringValue){}
Also, you could be overly cautious and check an object isn't null before you attempt to access members/methods of that object.