This is a mirror of official site: http://jasper-net.blogspot.com/

#772 – Initializing an Array as Part of a Method Call

| Tuesday, February 5, 2013
When you want to pass an array to a method, you could first declare the array and then pass the array by name to the method.

Suppose that you have a Dog method that looks like this:

public void DoBarks(string[] barkSounds)
{
    foreach (string s in barkSounds)
        Console.WriteLine(s);
}

You can declare the array and pass it to the method:

Dog d = new Dog();

// Declare array and then pass
string[] set1 = { "Woof", "Rowf" };
d.DoBarks(set1);

QR: Inline image 1

Posted via email from Jasper-net

0 comments: