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
Post a Comment