Convert class

  • Thread starter Thread starter Alberto
  • Start date Start date
A

Alberto

why there isn't a Convert.ToFloat() method in the Convert class?
Sometimes I can't work with a float field because there isn't this method
and I need it to, for example, convert the input in a textBox to a float
field.

Thank you
 
Alberto,

You will have to use the ToSingle method on the Convert class. This is
the name for a float in the BCL. Float is an alias provided by C#.

Hope this helps.
 
Alberto said:
why there isn't a Convert.ToFloat() method in the Convert class?
Sometimes I can't work with a float field because there isn't this method
and I need it to, for example, convert the input in a textBox to a float
field.

Because Float isn't the name of the type in question - Single is.
There's a Convert.ToSingle() method, just like there's
Convert.ToInt32() instead of Convert.ToInt().

The shorthand of "float" for System.Single is a C# notion, rather than
a .NET one.
 
Back
Top