08 06 Lecture1 Arrays PassingToMethods
08 06 Lecture1 Arrays PassingToMethods
Objectives
• Passing Array to Method
• Passing Array Element to Method
Passing an Array to a Method (continued)
static void Main(string[] args)
{
int i;
int[] originalArray = { 1, 2, 3, 4, 5 };
IncreaseAllByTen(originalArray);
DisplayColours(colours[2]);
Console.ReadLine();
} // end of void Main
DisplayColours(colours[2]);
Console.ReadLine();
} // end of void Main
• The colour “yellow” is passed through to the method (not the entire
array).
• It comes through as a normal string variable into the DisplayColor
method.