c# - error when setting a value for a property between forms -
i'm getting error:
cannot implicitly convert type decimal string
when i'm setting value property , i'm not sure how remedy this. there 2 forms. i'm passing information 1 form other display it. error in form price
form (calculator):
public partial class calculator : form { decimal dorm = 0; decimal meal = 0; public calculator() { initializecomponent(); } public decimal _price { { return _price; } } private void getpricebutton_click(object sender, eventargs e) { decimal price = 0; getinput(); price = dorm + meal; price myprice = new price(); myprice._pricelabel = _price; myprice.showdialog(); } private void getinput() { if(allenradiobutton.checked) { dorm = 1500; } if(pikeradiobutton.checked) { dorm = 1600; } if(farthingradiobutton.checked) { dorm = 1800; } if(universityradiobutton.checked) { dorm = 2500; } if(sevenradiobutton.checked) { meal = 600; } if(fourteenradiobutton.checked) { meal = 1200; } if(unlimitedradiobutton.checked) { meal = 1700; } }
form (price):
public partial class price : form { public price() { initializecomponent(); } public decimal _pricelabel { set { pricelabel.text = value; } // error } pricelabel.text = price.tostring("c"); //this messed } }
you cannot assign string
value decimal
. need convert it.
try this:
public decimal _pricelabel { set { pricelabel.text = decimal.parse(value); } // error }
Comments
Post a Comment