我从这种方法中得到了奇怪的结果:
public static double YFromDepth(double Depth, double? StartDepth, double? PrintScale)
{
return (Depth - StartDepth ?? Globals.StartDepth) * PrintScale ?? Constants.YPixelsPerUnit ;
}
当我将 null 传递给 StartDepth 时,合并失败,因为“Depth - StartDepth”似乎是通过首先将 StartDepth 转换为默认值 0(降级?)而不是首先查看它是否为 null 并替换为 Globals 来评估的。而是开始深度。
这是众所周知的事情吗?我能够通过添加括号来完成这项工作,但我真的没想到事情会以这种方式工作。