How, in C#, do I have a Func
parameter representing a method with this signature?
XmlNode createSection(XmlDocument doc, params XmlNode[] childNodes)
I tried having a parameter of type Func<XmlDocument, params XmlNode[], XmlNode>
but, ooh, ReSharper/Visual Studio 2008 go crazy highlighting that in red.
Update: okay, Googling for 'c# params func' produced no results, but 'c# params delegate' led me to this question. Following Jon Skeet's answer there, it looks like maybe I could create a delegate
, say Foo
, and then instead of having a parameter to my method of type Func<XmlDocument, params XmlNode[], XmlNode>
, I take a parameter of type Foo
.
Jon Skeet's answer to this other question led me to try the following, which works:
protected delegate XmlNode CreateSection(XmlDocument doc,
params XmlNode[] childNodes);
protected static void createOrUpdateSettingTree(XmlNode rootNode,
XmlDocument doc, CreateSection createSection) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With