top | item 27895884

(no title)

csharptwdec19 | 4 years ago

Same for C#. Any narrowing truncation needs to be an explicit cast. Widening is typically allowed implicitly, although in the case of the 'decimal' (128 bit struct representing a 'higher precision' floating point) type you still need an explicit cast from a 'double', since there are cases where that conversion can still change the value or fail (i.e. Infinity/NaN)

discuss

order

pjmlp|4 years ago

Microsoft is considering turning on by default checked arithmetic in the 2022 Visual Studio templates, by the way.