"alexrait1" wrote:[color=blue]
> how to express with codedom this:
> a.b[1].c[/color]
// assuming a is a variable
CodeVariableRef erenceExpressio n aRef =
new CodeVariableRef erenceExpressio n("a");
// assuming b is a field
CodeFieldRefere nceExpression bRef =
new CodeFieldRefere nceExpression(a Ref, "b");
CodePrimitiveEx pression index =
new CodePrimitiveEx pression(1);
CodeIndexerExpr ession bItem =
new CodeIndexerExpr ession(bRef, index);
// assuming c is a field
CodeFieldRefere nceExpression cRef =
new CodeFieldRefere nceExpression(b Item, "c");
Thats it. Alternatively, you can also use a quite convoluted single statement.
CodeFieldRefere nceExpression field =
new CodeFieldRefere nceExpression(
new CodeIndexerExpr ession(
new CodeFieldRefere nceExpression(
new CodeVariableRef erenceExpressio n("a"),
"b"),
new CodePrimitiveEx pression(1)),
"c");
Comment