加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何使用单位类型的值执行数学运算?

发布时间:2020-12-16 02:02:18 所属栏目:百科 来源:网络整理
导读:我有三个变量(asp.net中不同控件的宽度).他们的类型是单位. 我想做以下行动.例: Contol1.Width = Control2.Width - Control3.Width 现在我收到一个错误: Can’t apply operator “-” to operands of type “System.Web.UI.WebControls.Unit”. 我如何用这
我有三个变量(asp.net中不同控件的宽度).他们的类型是单位.

我想做以下行动.例:

Contol1.Width = Control2.Width - Control3.Width

现在我收到一个错误:

Can’t apply operator “-” to operands of type “System.Web.UI.WebControls.Unit”.

我如何用这个值进行数学运算?

解决方法

System.Web.UI.WebControls.Unit是一个可以使用 Value-property的结构.

Contol1.Width.Value - Control2.Width.Value - Control3.Width.Value

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读