Create instance of Public Method in RunScript error: C #

Hi I am currently switching from Python to C# and am getting a fairly simple error ‘Method must have a return type error’. I have added the ‘Curve’ return type after the access modifer, but is causing more issues. Apologies for the amateur question. Thanks.

Here is the code:

private void RunScript(Curve profile, Curve path, int num, ref object A)
  {
    OrientCurves oCrv = new OrientCurves();
    A = oCrv;
  }

  // <Custom additional code> 

  public OrientCurves()
  {
    Plane basePlane = new Plane(profile.GetBoundingBox(false).Center, Vector3d.ZAxis);
    path.Domain = new Interval(0, 1);

    List<Curve> orientedCrv = new List<Curve>();
    List<Plane> perpFrames = new List<Plane>();

    for (int i = 0; i < num; i++)
    {
      Plane plane;

      path.PerpendicularFrameAt((double) i / num, out plane); 
      perpFrames.Add(plane);

      Curve newCrv = profile.DuplicateCurve(); //why duplicate curve??
      newCrv.Transform(Transform.PlaneToPlane(basePlane, plane));
      orientedCrv.Add(newCrv);

    }
    return orientedCrv; //this seems to be wrong
  }

}

methodError.gh (5.9 KB)

If you want it to be a method you have to add the type in the initial declaration. Note you have to add the inputs inside the initial () after the declaration.

@felipegutierrezduque that’s what I thought and tried. When I add what you suggest, I am getting more errors. Clearly I am not understanding some basic method functionality.

Your are defining a Curve method but you are returning a List of Curve. And num is not declared as an input so there is no way that the OrientCurves method knows what num means.

Ok that makes sense; however I have declared the ‘num’ variable as an input into the GH component.

I tried renaming the methods as follows:

public List<Curve> OrientCurves(Curve crv)
public List<Curve> OrientCurves(List<Curve> orientedCrv)

But I am still getting errors. Thank you

line 57 is so wrong. You initiate a class which you never created, you defining a method below so you need to call it like method. This is not so much different to Python actually, which indicates you may missing basic knowledge about coding. I would advice to actually walk through basics before actually trying to implement a concrete functionality.

Thanks figured it out.

  private void RunScript(Curve profile, Curve path, int num, ref object A)
  {
   A = OrientCurves(crv, profile, num);
  }

  public List<Curve> OrientCurves(Curve crv, Curve profile, int num)
  {
    Plane basePlane = new Plane(profile.GetBoundingBox(false).Center, Vector3d.ZAxis);
    crv.Domain = new Interval(0, 1);

    List<Curve> orientedCrv = new List<Curve>();

      crv.PerpendicularFrameAt((double) i / num, out plane);
      perpFrames.Add(plane);

      Curve newCrv = profile.DuplicateCurve(); 
      List<Plane> perpFrames = new List<Plane>();
      newCrv.Transform(Transform.PlaneToPlane(basePlane, plane));
      orientedCrv.Add(newCrv);

    }
    return orientedCrv;
}