convert string into float C#
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();
}
}
3.78
9
float.Parse("41.00027357629127");
Thank you!
9
0
5
3
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);
Thank you!
3
0
4.4
5
Convert.ToSingle("41.00027357629127");
Thank you!
5
0
Are there any code examples left?
New code examples in category C#