O'Reilly logo

C# 2012 for Programmers, Fifth Edition by Paul Deitel, Harvey M. Deitel, Abbey Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Method FirstDouble

The for statement in method FirstDouble (lines 83–84) multiplies the values of all the elements in the array by 2. Line 87 creates a new array containing the values 11, 12 and 13, and assigns the array’s reference to parameter array in an attempt to overwrite reference firstArray in the caller—this, of course, does not happen, because the reference was passed by value. After method FirstDouble executes, the for statement at lines 33–34 displays the contents of firstArray, demonstrating that the values of the elements have been changed by the method. The if...else statement at lines 37–42 uses the == operator to compare references firstArray (which we just attempted to overwrite) and firstArrayCopy. The expression in line 37 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required