Q:

Can you pass an 'expanded' array to a function in C# like in ruby?

In ruby you can do something like this:
def method(a, b) ... end
myMethod(*myArray)

So if myArray had 2 items, it would be the equivalent of this:
myMehtod(myArray[0], myArray[1])

So that in the method body, a == myArray[0] and b == myArray[1]
Can you do this in C#? (So I can have a method declared with explicit arguments, instead of just taking an array as the argument)
EDIT: I should've been more specific about the method being called.

A:

Your method can be declared to accept a parameter array, via params:
void F(params int[] foo) {
    // Do something with foo.
}

Now you can either pass a arbitrary number of ints to the method, or an array of int. But given a fixed method declaration, you cannot expand an array on-the-fly as you can in Ruby, because the parameters are handled differently under the hood (I believe this is different in Ruby), and because C# isn’t quite as dynamic.
Theoretically, you can use reflection to call the method to achieve the same effect, though (reflected method calls always accept a parameter array).

A:

If you declare your function's arguments with the params keyword, you can pass in an array or an arbitrary number of individual parameters.
For instance:
public class Foo
{
    public static void Main()
    {
        int[] x = new int[] {1,2,3};
        Bar(x);
        Bar(10,11,12);
    }

    public static void Bar(params int[] quux)
    {
        foreach(int i in quux)
        {
            System.Console.WriteLine(i);
        }
    }
}

produces
1
2
3
10
11
12

