我正在尝试向称为offset
的几何函数传递一个可选参数,该参数可能会被指定,也可能不会被指定,但C#不允许我执行以下任何操作。有没有办法实现这个?
Null as default
Error: A value of type '' cannot be used as a default parameter because there are no standard conversions to type 'System.Drawing.Point'
public void LayoutRelative(.... Point offset = null) {}
Empty as default
Error: Default parameter value for 'offset' must be a compile-time constant
public void LayoutRelative(.... Point offset = Point.Empty) {}