Creating a method that takes a generic method and its variadic parameters as arguments and call it i
I need a way to pass generic static methods and its argument to another method, and the static method inside this another method.
In C++, I can easily achieve this with variadic templates and
But I don't know how to do this easily in C#;
Previously I just captured all the required arguments into a lambda, which calls the static method inside of it, and passed it as an single
But this breaks when I have non-capturable arguments such as
And I don't want to use
The only way I can think of is declaring the
But not only this is cumbersome, it would not work if sometimes the parameter needs to use
Is there any nice way to solve this like in C++?
In C++, I can easily achieve this with variadic templates and
std::forward:But I don't know how to do this easily in C#;
Previously I just captured all the required arguments into a lambda, which calls the static method inside of it, and passed it as an single
Action.But this breaks when I have non-capturable arguments such as
Span<T>.And I don't want to use
params object[]? to box the arguments.The only way I can think of is declaring the
ActualCallFunc one by one:But not only this is cumbersome, it would not work if sometimes the parameter needs to use
ref.Is there any nice way to solve this like in C++?