小编pol*_*pbl的帖子

更改此条件,使其不会始终评估为"true"

为什么SonarQube会抱怨这部分代码?

在此输入图像描述

我检查了这段代码并不总是这个值是真的.

public static void WriteJson(object value)
{
    decimal decimalValue = ((decimal?)value).Value;
    int intValue = (int)decimalValue;
    if (decimalValue == intValue)
        Console.WriteLine(intValue);
    else
        Console.WriteLine(decimalValue);
    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

为什么SonarQube抱怨这个?

.net c# sonarqube

5
推荐指数
1
解决办法
1512
查看次数

标签 统计

.net ×1

c# ×1

sonarqube ×1