Yes, that would fail if source
was null.
You'll have to decide what the correct behavior should be if source
is null. You might just throw an exception.
public Point3 ( Point3? source )
{
if (source == null)
{
throw new ArgumentNullException("source");
}
this.X = source.Value.X;
this.Y = source.Value.Y;
this.Z = source.Value.Z;
}
Or, if you don't want to accept null
values for source
, just keep the method as you have it in your example. That method doesn't accept a Nullable<Point3>
, so you don't have to worry about it being null
in that case.