why can’t I assign 1.2 value to float variable in C#? I did the same in C and C++, and it worked.
class Program
{
private readonly int a = 20;
private readonly float b;
public Program(float tmp)
{
b = tmp;
}
static void Main(string[] args)
{
Program obj1 = new Program(1.2);
Console.Read();
}
}
It gives error can not convet double to float.
Why is so isn’t 1.2 float value?
1.2is adouble(8 bytes).1.2fis afloat(4 bytes).More details