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

前端 未结 2 1689
南笙
南笙 2021-02-14 23:32

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:51

    try this

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

提交回复
热议问题