How can I fix the error : “Unreachable Code Detected”

后端 未结 4 1651
太阳男子
太阳男子 2020-12-04 00:22
public partial class KalenderLeeftijd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void calBirthDate_SelectionChanged(o         


        
4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-04 01:09

    Unreachable code is a compiler warning, not error. You have three options:

    • Remove the unreachable code.
    • Stop treating warnings as errors in the project properties.
    • Move the return statement to below what is currently unreachable.

    It is unreachable because the flow of the method exits at the return statement, and thus will never execute the code below. The compiler can determine this and so can report it. Like I said, these are actually compiler warnings and won't stop a successful build unless you have configured the project to treat warnings as errors.

提交回复
热议问题