开发者

Convert.ToSingle() for float data Type

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜