HOW TO PARSE THE VALUE TO FLOAT?

lois waisbrooker

Total Post:70

Points:494
Posted by  lois waisbrooker
C# 
C#
 1241  View(s)
Ratings:
Rate this:
Hi!

How to parse a value to float? When I try to parse that generate error as following

My line of code as following

float rt = float.Parse("12.50%");

Error message

System.FormatException: Input string was not in a correct format.

Please resolve my problem. 

Thank in advance!
  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How to parse the value to float?

    Hi Lois!


    Try as following

    float rt = float.Parse("12.50%".Replace("%",""));

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!