Code Providers – Convert to Integer
August 30th, 2012
The Convert to Integer code provider allows you to wrap an expression returning a non-integer value to Math.Ceiling, Math.Floor, or Math.Round. Consider the following code sample:
The method returns the sum of two input parameters as an integer. However, both input parameters are of the ‘double’ type. In this case, Visual Studio shows an error:
To fix this error, we can apply the Convert to Integer code provider and choose the rounding method:
Once the code provider is applied, the code is modified according to the preview hint: