c# - defaulting datatype double to 0 if input is null -


i having bit of difficulty setting variable 0 if user doesn't enter value textbox, making tricky because variable gets passed around multiple forms, if in same form easier do. code attached down below.

//in 1 of input forms //runs on button click if (!string.isnullorwhitespace(txtcustomergrowth.text)) {   fm.savegrowth(convert.todouble(txtcustomergrowth.text));   //fm instance of class methods save variables }  //in class public void savegrowth(double value) {     customergrowth = value; }  public double getgrowth() {     return customergrowth; }  //in final summary form double growth = fm.getgrowth(); 

i have tried saving variable string , converting double when need complains cannot convert type string double want know how can modify first if statement if textbox null set variable null (my issue being not sure how in situation because variable isnt created in input form.

edit:

i forgot mention runs fine have edit button on summary screen allows change values , when delete growth value , leave blank doesnt register , keeps growth same was.

edit2:

my edit button brings beginning values entered aren't deleted, when summary button pressed method called:

public void showsummary() {     calculatingform.show();     summaryform.updateform();     calculatingform.hide();     summaryform.show(); } 

and in updateform method is:

double growth = fm.getgrowth(); 

string foo = "21" double bar; if(double.tryparse(foo, out bar)) {  } 

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -