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);
Read more: 2,000 Things You Should Know About C#
QR:
0 comments:
Post a Comment