Why does the MS C# compiler complain that "not all code paths return a value" in the following scenario?
public int Foo(bool flag)
{
if(flag)
{
return 1;
}
else
{
ThrowException(); // this method always throws an exception
// return -1; // why do I need to add this code that will never be called?
}
}
Thanks!