Grasshopper, default function parameters in C# script

Hi all,

I’ve been playing with Grasshopper’s C# component, trying to see what’s possible to do with scripting.

I may be missing something basic, when I have a function with a default parameter, I get the message “default parameter specifiers are not permitted”. Is that how it should be?

I read here how to check GH’s .NET version, it’s 4.0, so it should be supported. I mostly read posts about optional parameter problems with component input, not plain functions/methods.

Ok, I can overload, and also this works but it’s not ideal:
void SomeFunction([InteropServices.DefaultParameterValue(“Default Value”)] string a) {…}

SomeFunction(string a = "DefaultValue")

Thanks. That’s how I was attempting it.

The above is marked red at the end of “DefaultValue” with the automatic popup that defaults are not permitted.

But I just realised, when I click the Play/Run icon, it actually works! There was an irrelevant mistake which made the whole script have no effects, that’s what confused me. I don’t get why the error pops up since it’s permitted after all.