Delegate function dynamic invoke output object

I think is mostly a dumb C# question as I am new to the language but I have banged my head against a wall long enough. I am trying to invoke a GH component in my custom component. I set up the delegate and then invoke it;

Rhino.NodeInCode.ComponentFunctionInfo TanCurveInfo = Rhino.NodeInCode.Components.FindComponent(“TangentCurve”);
var TanCurve = TanCurveInfo.Delegate;

object OutCurve = TanCurve.DynamicInvoke(Pnts, Tngnt, .5, 3);

OutCurve contains the 3 output arguments. I want to get just the curve (0th argument) out of that and into a curve type variable in my workspace. How do I do that? I’m going nuts. When I debug I can see the type is {object[3]} and each of those objects is a list. someone please tell me what obvious syntax thing I am missing…


See here:

You need to cast your object to IList<object>

This works:
2021-01-14 17_07_36-Grasshopper - unnamed

  private void RunScript(List<Point3d> Pnts, List<Vector3d> Tngnt, ref object C, ref object L, ref object D)
    Rhino.NodeInCode.ComponentFunctionInfo TanCurveInfo = Rhino.NodeInCode.Components.FindComponent("TangentCurve");
    System.Delegate TanCurve = TanCurveInfo.Delegate;
    IList<object> results = (IList<object>) TanCurve.DynamicInvoke(Pnts, Tngnt, 0.5, 3);    
    C = results[0];
    L = results[1];
    D = results[2];

How do I get the NurbsCurve in results[0] out to its own variable of type Rhino.Geometry.NurbsCurve?


Curve curveout = ((Curve)((IList)results[0])[0]);

Still getting used to List/IList thing…

Thanks Riccardo for your help.