C# explicitly defining what exceptions are thrown

前端 未结 6 584
礼貌的吻别
礼貌的吻别 2020-12-03 09:55

In Java, you explicitly define what exceptions are thrown using the \"throws\" keyword. That way, anyone calling your method knows what to catch.

Is there something

6条回答
  •  心在旅途
    2020-12-03 10:36

    There is nothing equivalent in C#: The Trouble with Checked Exceptions

    Other than documentation, there is no way to declare an interface to say "methodX() should throw this exception on error".

提交回复
热议问题