Is there any way to merge these two constructors into one? Basically they accept the same array of Point3D
type.
public Curve(int degree, params Point3D[] points) {}
public Curve(int degree, IList<Point3D> points) {}
Thanks.
If you want to have 2 different constructors you can:
public Curve(int degree, params Point3D[] points) : this(degree, (IList<Point3D>)points) { }
public Curve(int degree, IList<Point3D> points) { }
Or if you want only one constructor lets say the first then you can initialize like this:
new Curve(0,new List<Point3D>().ToArray());
By having one constructor calling the other you don't need to duplicate all your logic and you still enable both formats of initialization.
Though Array
implements IList<T>
one cannot remove the (IList<Point3D)
due to compile error of: compiler ...... cannot call itself
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With