I have been looking on stackoverflow, but do not see the ansswer yet. Note: that I did see some good responses in C++, but not C#.
Is there any benefit in checking for null if (reader == null)
as below, or will issues causing it to be null already cause an exception making if (reader == null)
unreachable (with reader == null being true)?
try
{
var reader = new PhotoReader();
if (reader == null)
{
throw new InvalidOperationException("PhotoReader could not be created.");
}
}
catch (Exception ex)
{
// let user know failed object creation, etc.
<...>
}