As the title suggests, I am trying to “nest” – or create an array within an array in C# using CodeDom.
Here is the line that I am trying to replicate:
T.Invoke(null, new object[] { new string[] {} } );
Where T.Invoke is a method.
I am able to create the above line with almost no flaws. The only issue I have is creating the second set of “{}” brackets. Below is the code I used:
CodeMethodInvokeExpression invoke_expression = new CodeMethodInvokeExpression(
new CodeTypeReferenceExpression("T"),"Invoke",
new CodePrimitiveExpression(null),
new CodeArrayCreateExpression(typeof(object),
new CodeExpression[] {
new CodeArrayCreateExpression(typeof(string[]),
new CodeExpression[] {})} )));
Perhaps someone could make sense of my code, and maybe even find my error.
Thank you for any help,
Evan
Use an empty
CodeSnippetExpressionto coerce it into creating the brackets: