开发者

Why is there no Convert.toFloat() method?

开发者 https://www.devze.com 2023-03-31 10:19 出处:网络
Why there is not exist method Convert.ToFloat(),C# has ToDouble(),ToDecimal()...I want convert to f开发者_运维百科loat, which method can be used? (float)var?There is - but it\'s called Convert.ToSingl

Why there is not exist method Convert.ToFloat(),C# has ToDouble(),ToDecimal()...

I want convert to f开发者_运维百科loat, which method can be used? (float)var?


There is - but it's called Convert.ToSingle(). float is a C# alias for the System.Single type.

"Single" is the name for a float in the BCL. "float" is an alias provided by C#. There's a Convert.ToSingle() method, just like there's Convert.ToInt32() instead of Convert.ToInt().

See this thread Convert class

(BTW - I didn't know this either, so I learned something new today :) )

0

精彩评论

暂无评论...
验证码 换一张
取 消