c# - My logical is wrong somehow -


this should simple, somehow not. messagebox displays zero's both product quantity , product total price. not quite sure why. here code far:

product page

//will add qty of tshirts shop page. catch non-integers protected void linktshirtadd_click(object sender, eventargs e) {     int intoutput = 0;     lbltshirtwarning.visible = false;      //determine value parsable - if is, assign values. else, display error     if (int.tryparse(txttshirtqty.text, out intoutput))     {         productclass.productname = "t-shirt";         productclass.productprice = 10;         productclass.productqty = int16.parse(txttshirtqty.text);         //price of tshirts         int totaltshirtprice = productclass.productprice * productclass.productqty;         //display summary of order         messagebox.show (new form {topmost = true},             "order review" + "\n_______________________\n"             + productclass.productname + "\n"              + "quantity: " + productclass.productqty +"\n"              + "total price: " + totaltshirtprice);         //response.redirect("./shop.aspx");     }     else     {         lbltshirtwarning.visible = true;         lbltshirtwarning.text = "please enter valid number";         txttshirtqty.text = "";     } } 

product class (to store values)

using system; using system.collections.generic; using system.linq; using system.web;  /// <summary> /// summary description productclass /// </summary> public static class productclass {  //obvious variables private static string product; private static int price; private static int quantity;  //get , set name of product public static string productname {         {         return product;     }     set     {         product = value;     } }  //get , set price of product public static int productprice {         {         return price;     }     set     {         price = value;     } }  //get , set quantity of product public static int productqty {         {         return quantity;     }     set     {         price = value;     } }   } 

the getter , setter of productcode.productqty use different backing fields:

 public static int productqty  {           {          return quantity;      }      set      {          price = value;      }  } 

obviously, in setter, price = value; wrong, meant quantity = value;.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -