Invoking proper overloads in C# Rhinocommon API

Hi there,

I have a question about invoking the proper overloads in C# with the overloads provided in the Rhinocommon API.

I ran into this issue with the GeometryBase.GetBoundingBox Method - the method describes 4 different overloads:

  1. GetBoundingBox(Boolean)
  2. GetBoundingBox(Plane)
  3. GetBoundingBox(Transform)
  4. GetBoundingBox(Plane, Box)

However, it seems like the compiler only recognises the 3rd overload - GetBoundingBox(Transform). Feeding a Plane or a Boolean to the method returns a conversion error. How can I use the other overloads given by the RhinCommon API?

I’m working on Visual Studio with the latest RhinoCommon and Grasshopper template.

Thank you all!

When you have multiple overloads for a method, the C# compiler will try to choose the best match based on the arguments that you provide. In some cases, it can be ambiguous which overload should be called, and you may need to provide more information to disambiguate.

In your case, it seems that the compiler is having trouble choosing between the overloads because the argument you are providing could be interpreted as either a Plane or a Boolean. To disambiguate, you can use an explicit cast to the type you want
I hope this helps!

1 Like