如何将cobobox和unitprice中的项目相乘? [英] how can i multiply the items in cobobox and unitprice?

查看:81
本文介绍了如何将cobobox和unitprice中的项目相乘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我该如何将组合框和单价中的项目相乘?运算符"*"以产生结果:

  int  x =  int  .Parse(myCombo.SelectedItem.ToString() );
 int  y =  int  .Parse(myTextbox.Text);
 int  res = x * y; 


  int  .Parse(Product.SelectedValue.ToString());
 int  unitPrice =  int  .Parse(UnitPrice.SelectedValue.ToString());

 int  result = item1 * unitPrice 


how can i multiply the items in combobox and unitprice?

解决方案

Convert them to numbers, using Parse or TryParse, and (as Richard says) use the multiplication operator "*" to produce a result:

int x = int.Parse(myCombo.SelectedItem.ToString());
int y = int.Parse(myTextbox.Text);
int res = x * y;


int item1 =int.Parse(Product.SelectedValue.ToString());
int unitPrice=int.Parse(UnitPrice.SelectedValue.ToString());

int result = item1 *  unitPrice


这篇关于如何将cobobox和unitprice中的项目相乘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆