This is the second time I ask this question because it has been marked as duplicate, but my problem still not been solved and I can't figure it out.
From Link 1: This code below is from the accepted answer, but doesn't work.
CS0306 The type 'ReadOnlySpan' may not be used as a type argument
var delegateCtor = Expression.Lambda<Func<ReadOnlySpan<byte>,object>>
(ctorCall, new ParameterExpression[] { param }).Compile();
So my question again:
In .Net Framework BigInteger
has a constructor what I can invoke as this:
ConstructorInfo _ctor = typeof(BigInteger).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null,
new Type[] { typeof(UInt32[]), typeof(Boolean) }, null);
BigInteger result = (BigInteger)_ctor.Invoke(new Object[] { new UInt32[] { 42, 69, 314 }, false });
Recently swapped to .Net Core and the constructor changed to:
ConstructorInfo _ctor = typeof(BigInteger).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance,
new Type[] {typeof(ReadOnlySpan<UInt32>), typeof(Boolean) });
So the logical step was:
BigInteger result = (BigInteger)_ctor.Invoke(new Object[] { new ReadOnlySpan<UInt32>(new UInt32[] { 42, 69, 314 } ), false } );
But I'm getting an error.
Error CS0029 Cannot implicitly convert type 'System.ReadOnlySpan' to 'object'.
How can I invoke a constructor what takes 2 arguments and one of them is a ReadOnlySpan
?
Thank you
Aucun commentaire:
Enregistrer un commentaire