Difference between long and int in C#?

后端 未结 6 658
日久生厌
日久生厌 2021-02-03 17:40

What is the actual difference between a long and an int in C#? I understand that in C/C++ long would be 64bit on some 64bit platforms(depending on OS o

6条回答
  •  猫巷女王i
    2021-02-03 18:44

    int in C#=> System.Int32=>from -2,147,483,648 to 2,147,483,647.

    long in C#=> System.Int64 =>from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

    If your long data exceeds the range of int, and you use Convert.ToInt32 then it will throw OverflowException, if you use explicit cast then the result would be unexpected.

提交回复
热议问题