I have a method in C# 4.0 that is like this:
protected override bool _update()
{
if (this.Notes == "")
throw new Exception("Some message...");
else
base._update();
}
The compiler complains that not all code paths return a value, however, if I were to do this:
protected override bool _update()
{
throw new Exception("Some message...");
}
it compiles okay. Are there recommended ways of getting around this? Seems like they really aren’t all that different, if an exception in one case suffices for no return value, why wouldn’t it in the other case?
Give this a shot 🙂
You just need to return the output of base._update(), it’s not enough to just run it because the value wouldn’t get returned.