Answers for "c# convert to float"

C#
7

c# string to float

  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();
 
        }
    }
Posted by: Guest on March-12-2020
11

float to int c#

Convert.ToInt32(float)
Posted by: Guest on April-30-2020
5

C# Cast double to float

double double_Num = 42.0349384093;
float float_Num = (float)dNum;

By Barry Cox
Posted by: Guest on March-18-2020
1

how to convert int to float in c#

int val1 = 1;
float val2 = (float)val1;
Posted by: Guest on September-14-2021
6

how to convert float to int c#

float someFloat = 42.7f;
int someInt = (int)someFloat;               // 42
Posted by: Guest on July-01-2020
0

c# string to float

string s1 = "1.0"
float f1 = float.Parse(s1);

// Change the delimiter - (The default delimiter is based on your current CultureInfo)
var ci = (CultureInfo)CultureInfo.CurrentCulture.Clone();
ci.NumberFormat.NumberDecimalSeparator = ",";

string s2 = "1,1";
float f2 = float.Parse(s2, ci);
Posted by: Guest on October-19-2020

C# Answers by Framework

Browse Popular Code Answers by Language