what is the difference between
-
"(int)parameterItemID.Value" and "Convert.ToInt32(parameterItemID.Value)" can somebody help me? thanks!!
Hi, The first is an explicit conversion (called casting), the other uses a system conversion object. The latter will throw an InvalidCastException if no meaningful conversion can be performed. If you do use the explicit cast, you could find the value outputted of an indeterminate value. You could use the checked C# command to offer some protection but this only throws an OverflowException if the result is out of bounds for the data type. My advice would be to always use Convert.Toxxxx when converting types. Hope this helps, Andy
-
Hi, The first is an explicit conversion (called casting), the other uses a system conversion object. The latter will throw an InvalidCastException if no meaningful conversion can be performed. If you do use the explicit cast, you could find the value outputted of an indeterminate value. You could use the checked C# command to offer some protection but this only throws an OverflowException if the result is out of bounds for the data type. My advice would be to always use Convert.Toxxxx when converting types. Hope this helps, Andy