This is probably not possible, but here goes:
I want to create a struct where I can define the amount of arguments at declaration.
for example, now I am using:
KeyValuePair<T, T>
but KeyValuePair can only ever take a Key , and a Value .
Is it possible to make something like:
CustomValues<T, {T, {..}}>
I think this isn't possible, but maybe I just don't know enough C#. I'm also open to clever workarounds,
Thank you
Variable length argument is a feature that allows a function to receive any number of arguments. There are situations where we want a function to handle variable number of arguments according to requirement. 1) Sum of given numbers. 2) Minimum of given numbers.
Variable-length arguments, abbreviated as varargs, are defined as arguments that can also accept an unlimited amount of data as input. The developer doesn't have to wrap the data in a list or any other sequence while using them. Let's understand the concept with the help of an example.
Variable-length argument lists, makes it possible to write a method that accepts any number of arguments when it is called. For example, suppose we need to write a method named sum that can accept any number of int values and then return the sum of those values.
No, this isn't possible, as showcased by Func<T>
, Func<T, TResult>
, Func<T1, T2, TResult>
, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With