The Tech Platform

Mar 9, 20211 min

Program to Convert String To Float In C#

In this article, we will write a C# program to convert String to Float using float.Parse() method

class Program
 
{
 
static void Main(string[] args)
 
{
 
string str1 = "5.682";
 
string str2 = "4.137";
 
float flt1 = float.Parse(str1);
 
float flt2 = float.Parse(str2);
 
Console.WriteLine(flt1 + flt2);
 
Console.ReadLine();
 

 
}
 
}
 

Output:

9.819

Read more :

  1. Convert Float to String

  2. Convert Integer to String

  3. Convert String to Integer

Source: Wikipedia

The Tech Platform

www.thetechplatform.com

    0