Optional Input does not work

To set some of the input parameters optional i defined as such
pManager.AddTextParameter(“Road Categories”, “RC”,
“Road Categories corresponding to Site Boundary Definition”, GH_ParamAccess.list);
pManager[2].Optional = true;

However, my componenet still doesnt run. It gives me this error

Input parameter failed to collect data

I usually do it like this, so you never make a mistake with the index:

Params.Input[
  pManager.AddTextParameter("Road Categories", "RC","Road Categories corresponding to Site Boundary Definition", GH_ParamAccess.list)
].Optional = true;

I did the same thing and it still gave me the error. but thx

Huh, weird :confused: What about the other inputs?

I figure it’s because of the way I defined of getting data. Think this might help others.

Previously, I defined as such.
if (!DA.GetDataList(2, roadCat)) { return; }

Instead, if I define in this way, it works fine:
DA.GetDataList(2, roadCat);

Yep, that’s the correct way of doing it.

This didn’t help me…
Does it matter that it’s a generic parameter and a custom type?

oh never mind, it works fine. Sorry!