What's the VB.NET method corresponding to the old CInt() VB method?
.net, double, methods, type-conversion, vb.net
Solution
You can use CInt in VB.NET as well. It is a standard type conversion function supported by the VB.NET compiler. There is no reason to avoid it.
However, nearly every type conversion operation will round to the nearest integer (including other methods such as Convert.ToInt32, etc.), not truncate. You can force a truncation by using Int or Fix (which have different behaviors for negative numbers).
Note that, you can do the same as Int/Fix by using Math.Truncate and Math.Floor, should you wish to avoid the VB.NET specific conversion routines.
On a side note - CInt in Visual Basic 6.0 also performed rounding. The behavior in VB.NET for `CInt` is the same as in Visual Basic 6.0.
Problem
I don't want use old Visual Basic methods in my code, and I'm confused about what's the newest VB.NET method corresponding to the old CInt() Visual Basic method. For example, ``` Dim n1 as Double : n1 = CInt(2.1111111) 'Gets only 2 without rounding it Dim n2 as Double : n2 = CInt(2.7777777) 'Get only 2 without rounding it ```