Convert a String to Float in C#

How do i convert a string value to corresponding float value in C#?

Comments

  • : How do i convert a string value to corresponding float value in C#?
    :
    [code]
    string s = "124.53";
    try
    {
    float f = (float)double.Parse(s);
    }
    catch(FormatException ex)
    {
    // handle error here (if s is empty, has characters, etc)
    }
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion