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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -