public static Equal ( |
||
left | An |
|
right | An |
|
return |
var x = Expression.Parameter(typeof(int), "x"); var y = Expression.Parameter(typeof(int), "y"); var equalExpr = Expression.Equal(x, y);
var list = new ListThis code creates an `Equal` expression that checks if the count of the `int` list is equal to 1. It then compiles this expression and uses it to filter elements from the list by using `Where` method. The System.Linq.Expressions package library is used for creating and manipulating expression trees.{ 1, 2, 3, 1, 2 }; var equalExpr = Expression.Equal( Expression.Constant(1), Expression.Property( Expression.Constant(list), "Count" ) ); var result = list.Where(Expression.Lambda >(equalExpr, x).Compile());
public static Equal ( |
||
left | An |
|
right | An |
|
return |