c# - how to call a method in another method with return? -


i relatively new c# programming. working forms , want print value in text box not working. getting error "not code paths return value"

public void button1_click(object sender, eventargs e) {     double res = test();     tbox.text = res.tostring();  }  public double test() {     if (cbtest.checked == false)     {         return 10 + 5.1;     } } 

the issue test method, need consider cbtest.checked==true condition otherwise code raise error "not code paths return value", better change signature following:

public double test() {     if (!cbtest.checked)     {         return 10 + 5.1;     }     return 0.0; // or other values } 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -