I am trying to pass an optional argument to a geometry function called offsetthat may or may not be specified, but C # does not allow me to do one of the following: Is there any way to do this?
offset
Default zero
Error: a value of type '' cannot be used as the default parameter, because there are no standard conversions for entering "System.Drawing.Point"
public void LayoutRelative(.... Point offset = null) {}
Empty by default
Error: The default parameter value for 'offset' must be a compile-time constant
public void LayoutRelative(.... Point offset = Point.Empty) {}
, . default:
default
public void LayoutRelative(.... Point offset = default(Point)) {}
:
public void LayoutRelative(.... Point? offset = null) { if (offset.HasValue) { DoSomethingWith(offset.Value); } }