I saw some code written by another developer that looks something like this:
var stringBuilder = new StringBuilder();
if(stringBuilder == null)
{
// Log memory allocation error
// ...
return;
}
(It is ALL over the place in the code )
Question 1:
Would that error logging code even get called? If there was no memory, wouldn't an System.OutOfMemoryException
be thrown on that first line?
Question 2: Can a call to a constructor ever return null?