我想使用 Track-Bar 来更改 Form 的不透明度.
这是我的代码:
十进制 trans = trackBar1.Value/5000;this.Opacity = 反式;当我构建应用程序时,它给出了以下错误:
<块引用>不能将十进制类型隐式转换为双精度我曾尝试使用 trans 和 double,但随后 Control 不起作用.此代码在过去的 VB.NET 项目中运行良好.
不需要像这样显式转换为 double:
double trans = (double) trackBar1.Value/5000.0;将常量标识为5000.0(或5000d)就足够了:
double trans = trackBar1.Value/5000.0;双反 = trackBar1.Value/5000d;I want to use a Track-Bar to change a Form's opacity.
This is my code:
decimal trans = trackBar1.Value / 5000;
this.Opacity = trans;
When I build the application, it gives the following error:
Cannot implicitly convert type decimal to double
I have tried using trans and double, but then the Control doesn't work. This code worked fine in a past VB.NET project.
An explicit cast to double like this isn't necessary:
double trans = (double) trackBar1.Value / 5000.0;
Identifying the constant as 5000.0 (or as 5000d) is sufficient:
double trans = trackBar1.Value / 5000.0;
double trans = trackBar1.Value / 5000d;
这篇关于如何在 C# 中将 Decimal 转换为 Double?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ASP.NET Core 使用 Azure Active Directory 进行身份验证并ASP.NET Core authenticating with Azure Active Directory and persisting custom Claims across requests(ASP.NET Core 使用 Azure Active Directory 进行身
ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用ASP.NET Core 2.0 Web API Azure Ad v2 Token Authorization not working(ASP.NET Core 2.0 Web API Azure Ad v2 令牌授权不起作用)
如何获取守护进程或服务器到 C# ASP.NET Web API 的How do I get Azure AD OAuth2 Access Token and Refresh token for Daemon or Server to C# ASP.NET Web API(如何获取守护进程或服务器到 C# ASP.N
异步调用时 Azure KeyVault Active Directory AcquireTokenAAzure KeyVault Active Directory AcquireTokenAsync timeout when called asynchronously(异步调用时 Azure KeyVault Active Directory AcquireTokenAsync 超
使用电子邮件地址和应用程序密码从 oauth2/tokenGetting access token using email address and app password from oauth2/token(使用电子邮件地址和应用程序密码从 oauth2/token 获取访问令
新的 Azure AD 应用程序在通过管理门户更新之前无New Azure AD application doesn#39;t work until updated through management portal(新的 Azure AD 应用程序在通过管理门户更新之前无法运行