本文整理匯總了C#中System.Linq.Expressions.NewArrayExpression類的典型用法代碼示例。如果您正苦於以下問題:C# NewArrayExpression類的具體用法?C# NewArrayExpression怎麽用?C# NewArrayExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NewArrayExpression類屬於System.Linq.Expressions命名空間,在下文中一共展示了NewArrayExpression類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1:
List<System.Linq.Expressions.Expression> trees =
new List<System.Linq.Expressions.Expression>()
{ System.Linq.Expressions.Expression.Constant("oak"),
System.Linq.Expressions.Expression.Constant("fir"),
System.Linq.Expressions.Expression.Constant("spruce"),
System.Linq.Expressions.Expression.Constant("alder") };
// Create an expression tree that represents creating and
// initializing a one-dimensional array of type string.
System.Linq.Expressions.NewArrayExpression newArrayExpression =
System.Linq.Expressions.Expression.NewArrayInit(typeof(string), trees);
// Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString());
輸出:
new [] {"oak", "fir", "spruce", "alder"}
示例2: typeof
// Create an expression tree that represents creating a
// two-dimensional array of type string with bounds [3,2].
System.Linq.Expressions.NewArrayExpression newArrayExpression =
System.Linq.Expressions.Expression.NewArrayBounds(
typeof(string),
System.Linq.Expressions.Expression.Constant(3),
System.Linq.Expressions.Expression.Constant(2));
// Output the string representation of the Expression.
Console.WriteLine(newArrayExpression.ToString());
輸出:
new System.String[,](3, 2)