开发者

Convert.ToSingle() for float data Type

开发者 https://www.devze.com 2022-12-25 04:41 出处:网络
I have used many of the Convert.To..... functions for conversion , but I didn\'t understand one thing that for every datatype they have provide a Convert.To function but not for float datatype, in ord

I have used many of the Convert.To..... functions for conversion , but I didn't understand one thing that for every datatype they have provide a Convert.To function but not for float datatype, in order to convert 开发者_JAVA技巧to float you need to use Convert.ToSingle() , why is this so ?


Single is the CTS (Common Type System for .NET) type, float is the C# shorthand for it.

Int32 CTS -> int C#
String CTS -> string C#
Double CTS -> double C#
Single CTS -> float C#
Int16 CTS -> short C#
Int64 CTS -> long C#

etc.

The Convert methods are .NET methods and therefore use the CTS names and not the C# shorthands.

0

精彩评论

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