Converting object to float

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
I can't seem to do anything with float! I cannot even seem to convert a float value into a string or vice versa. Can someone help?
 
This is all I have found that works:

MessageBox.Show(""+(float)Convert.ToDouble(CommunicationLog.settings.GetValue("TitleFont.Size")));
 
Or

Convert.ToSingle(CommunicationLog.settings.GetValue("TitleFont.Size")

Is single a float value?
 
If you opened your help file, you would find that the C# float type maps to the Single type in the framework.

You can use Single.Parse to convert a string to a Single, and use the ToString method on a Single instance to convert it to a string.
 
Back
Top