Почему компилятор MS C# сообщает, что «не все пути кода возвращают значение» в следующем сценарии?
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?
}
}
Подробнее здесь: https://stackoverflow.com/questions/348 ... exceptions
Мобильная версия