JetBrains Rider 2026.1 Help

代码检查:可能的溢出​

此检查会报告在可能发生溢出的 int 值上的算术运算。 溢出指的是计算出的值无法适应 int 范围。

示例

int itemCount = 50_000; int price = 50_000; int total = itemCount * price;

乘法结果无法适应 int

如何修复

此检查没有专用的快速修复方案。 常见的修复方法是使用更宽的数据类型、验证输入范围或显式处理溢出行为。

int itemCount = 50_000; int price = 50_000; long total = (long)itemCount * price;
2026年 5月 8日