Replies: 1 comment
-
System.Linq.Expressions does not have any explicit support for System.Index. This means that for methods that actually take var param = Expression.Parameter(typeof(int[]));
Func<int[], Index, Memory<int>> asMemory = MemoryExtensions.AsMemory<int>;
var expression = Expression.Lambda<Func<int[], Memory<int>>>(
Expression.Call(asMemory.Method, param, Expression.Constant(^1)), param);
var lastItem = expression.Compile().Invoke(new int[] { 1, 2, 3 }); Though most of the common operations that use the index syntax in C# aren't like that, so you can't use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
My question is if a System.Index can somehow be used in System.Linq.Expressions like this
Expression.ArrayAccess(arrayExpr, Expression.Constant(^1));
Or is this a Roslyn only feature?
Beta Was this translation helpful? Give feedback.
All reactions