How to parse the value to float?

Total Post:70

Points:494

C# 
C#
 1800  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. Re: How to parse the value to float?

    Hi Lois!


    Try as following

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

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.