Why C# does not require explicit casting for convert Long To Double?

前端 未结 2 1011
面向向阳花
面向向阳花 2021-02-14 23:26

At first, sorry for my bad english. I have fragment of code:

long x = 9223372036854775807L;
double f = x;
Console.WriteLine(x);           
Console.WriteLine(f);
         


        
2条回答
  •  长发绾君心
    2021-02-14 23:49

    try this

    long x = 9223372036854775807L;
    decimal f = x;
    Console.WriteLine(x);
    Console.WriteLine(f);
    

提交回复
热议问题