Is it possible to "spread" array elements in c# so that I can pass them to another function?
For example, in Javascript, we can do
function myFunction(x, y, z) { }
var args = [0, 1, 2];
myFunction(...args);
Is there a similar functionality in c#? The reason I want to do this is that I have a SQL statement with a lot of columns and I want to instantiate a new object with each row without having to explicitly set each field to a particular column. I can use reader.GetValues
to get an array of all my column values, but can I use this to conveniently create objects?