【发布时间】:2010-09-05 05:27:08
【问题描述】:
我想使用Track-Bar 来更改Form 的不透明度。
这是我的代码:
decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;
当我构建应用程序时,它给出了以下错误:
Cannot implicitly convert type decimal to double
我曾尝试使用trans 和double,但随后Control 不起作用。此代码在过去的 VB.NET 项目中运行良好。
【问题讨论】:
-
另外,Decimal 不能表示像 Double 一样宽的值。十进制最多只能达到 +/-7.9228162514264337593543950335E+28;而 Double 可以达到 +/-1.79769313486232E+308
-
@TraumaPony 这是一个
trackbar。在trackbar上使用如此高的价值是不可能的。 -
总是有人告诉我,乘以 0.0002 比除以 5000 更好。
标签: c# floating-point type-conversion double decimal