[cs] Use toDouble to guard against boxed int -> double class cast error. Closes #2304