Convert float to string in C#

In this article we will discuss about how to convert from float to string.
  • 7461

Here we are converting from float to string data type. For this we will use ToString() method.
 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            float f = 23.55f;
            float f1 = 34.54f;
            string ss = f.ToString();
            string ss1 = f1.ToString();
            Console.WriteLine(ss + ss1);
            Console.ReadLine();
        }
    }
}

 

 
Here two float variables have been taken i.e. f & f1 and have been converted into string variables. As a result they will be concatenate and gives the output as 23.5534.54

Ask Your Question 

 
Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.