gpt4 book ai didi

c# - 如何对 Unit 类型的值进行数学运算?

转载 作者:行者123 更新时间:2023-11-30 14:10:21 25 4
gpt4 key购买 nike

我有三个变量(asp.net 中不同控件的宽度)。它们的类型是 Unit

我要执行以下操作。示例:

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

关于c# - 如何对 Unit 类型的值进行数学运算?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24409474/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com