I have created a method called "tag" that returns an HtmlTag object and get params of type "HtmlTag" (See below).

I'm trying to pass the params without an inline array but I get an error: "Named argument specifications must appear after all fixed arguments have been specified".

The error resolved only by inserting the params in an inline array (which I really don't want to).

Can't I pass the params without an array?

protected HtmlTag tag(string tagName, string id = null, string classes = null, 
     Dictionary<string, object> attributes = null, Dictionary<string, object> data = null, 
     string text = null, params HtmlTag[] content)
{yada yada...}

See below how I call the method from above:

tag("form", "", attributes: ObjList("...."), content: 
                    tag("input", "token", attributes: ObjList("..." + token + "...")),
                    tag("label", "...", attributes: ObjList("..."), text: "..."),
                    tag("...", "...", attributes: ObjList("...")));

I have no errors when I insert the "content" params value inside an inline array of HtmlTag (see below):

tag("form", "", attributes: ObjList("...."), content: new HtmlTag[] {
                    tag("input", "token", attributes: ObjList("..." + token + "...")),
                    tag("label", "...", attributes: ObjList("..."), text: "..."),
                    tag("...", "...", attributes: ObjList("..."))});
1

There are 1 best solutions below

1
Loves2Develop On

Thanks to Nyerguds and Jcl I'm using overloaded method as an answer. Seems like it is the only way to go (other than inline array)