转换为两个十进制值 [英] convert to two decimal value

查看:108
本文介绍了转换为两个十进制值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在VB.NET中将12或12.0转换为12.00.

How to convert 12 or 12.0 to 12.00 in VB.NET.

推荐答案

这个问题没有任何意义.您显示的只是字符串,而不是数字.在对应于12.0和12.00的浮点值相同的情况下,12可能是整数类型,因此可以不同,但​​是随后将其强制转换为任何浮点类型都将得到相同的值.

您没有想过的那种转换".可以使用格式参数附带的方法ToString将数字类型的值表示为字符串.有关字符串格式,请参见:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx [ ^ ].

—SA
The question makes no sense. What you show are just strings, not numbers. In floating-point values corresponding to 12.0 and 12.00 are the same, 12 could be of integer type, so it can be different, but then its cast to any of floating-point types makes the same value.

There is no "convert" of the sort you are trying to think of. A numeric-type value can be represented as a string using the method ToString which can come with formatting parameter(s). For string formatting, please see:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^],
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^].

—SA


这篇关于转换为两个十进制值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆