What is the best way to convert a double
to an int
? Should a cast be used?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
The best way is to simply use
Convert.ToInt32
. It is fast and also rounds correctly.Why make it more complicated?
Convert.ToInt32
is the best way to convertYeah, why not?
Using the
Convert
class works well too.My ways are :