C# Add Range fails in a list of lists

I create a List< Line> alpha and a List<List< Line>> beta.
Add to alpha a bunch of lines.


  1. Error (CS1502): The best overloaded method match for ‘System.Collections.Generic.List<System.Collections.Generic.List<Rhino.Geometry.Line>>.AddRange(System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Rhino.Geometry.Line>>)’ has some invalid arguments
  2. Error (CS1503): Argument 1: cannot convert from ‘System.Collections.Generic.List<Rhino.Geometry.Line>’ to ‘System.Collections.Generic.IEnumerable<System.Collections.Generic.List<Rhino.Geometry.Line>>’

What’s the problem? How is one of the category System.Collections.Generic.IEnumerable & the other System.Collections.Generic.List?

Thank you.

Hi Ucbqeor
You should use beta.Add(alpha).If you want to use AddRange(), you need beta.AddRange(new List<List>{alpha});

Line is a protected constructor and should be replaced by a List containing curves and then add them as NurbsCurve.

something like this:

Curve crv = new Line(pt0,pt1).ToNurbsCurve();

for your example, List<Line> should be replaced by List<Curve> and the Lines added as NurbsCurve.

1 Like

Thank you!

No - do not convert lines to NURBS curve.

Do this instead:

var line = new Line(pt0, p1);
var line_curve = new LineCurve(line);

– Dale

1 Like

Oh, sorry I mislead then.
Must have missed out that one…
LineCurve? is that one new or did I miss it since ever?

Ben back in NooB modus :slight_smile: