calculating a percentage from a value C# -


i'm trying output percentage value imputed textbox. here code;

int firstnumber; double mydouble1 = 0.15; int myint1 = (int)mydouble1;  int.tryparse(housevalue.text, out firstnumber);  int answer; answer = (firstnumber) * (myint1); prem1.text = answer.tostring(); 

the problem when run app , enter value calculate, answer 0. cant seem display correct amount 0.15% of value.

try this: change answer int double:

int firstnumber; double mydouble1 = 0.15;  if (int.tryparse(housevalue.text, out firstnumber)) {     double answer = firstnumber * mydouble1;     prem1.text = answer.tostring(); // may want round/format } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -