Dim x as Decimal = 100.0m 是否隐式地从双精度转换为十进制? [英] Does Dim x as Decimal = 100.0m do a cast from double to decimal implicitly?
本文介绍了Dim x as Decimal = 100.0m 是否隐式地从双精度转换为十进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有代码:
Dim x as Decimal = 100.0m
它是否隐式地从双精度转换为小数.我将如何在 vb.net 中明确地执行此操作?
Is it casting from a double to a decimal implicitly. How would I do this explicitly in vb.net?
推荐答案
我想你想要:
Dim x as Decimal = 100.0d
C# 中的十进制文字是 m
,但在 vb.net 中是 d
.这不会产生任何铸造.要将 double 转换为小数(r
是 vb.net 中的 double 文字),您可以说:
The decimal literal in C# is m
, but is d
in vb.net. This produces no casting whatsoever. To cast a double to a decimal (r
is the double literal in vb.net) you could say:
Dim x as Decimal = CType(100r, Decimal)
Dim x as Decimal = CType(100.0, Decimal)
这篇关于Dim x as Decimal = 100.0m 是否隐式地从双精度转换为十进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文