Web hosting asp - Chapter 7 Arrays 255 51 // test whether

Chapter 7 Arrays 255 51 // test whether reference was changed by FirstDouble 52 if ( firstArray == firstArrayCopy ) 53 outputLabel.Text += 54 “nnThe references refer to the same arrayn”; 55 else 56 outputLabel.Text += 57 “nnThe references refer to different arraysn”; 58 59 // create and initialize secondArray 60 int[] secondArray = { 1, 2, 3 }; 61 62 // copy secondArray reference 63 int[] secondArrayCopy = secondArray; 64 65 outputLabel.Text += “nTest passing secondArray ” + 66 “reference by reference”; 67 68 outputLabel.Text += “nnContents of secondArray ” + 69 “before calling SecondDouble:nt”; 70 71 // print contents of secondArray before method call 72 for ( int i = 0; i < secondArray.Length; i++ ) 73 outputLabel.Text += secondArray[ i ] + " "; 74 75 SecondDouble( ref secondArray ); 76 77 outputLabel.Text += "nnContents of secondArray " + 78 "after calling SecondDouble:nt"; 79 80 // print contents of secondArray after method call 81 for ( int i = 0; i < secondArray.Length; i++ ) 82 outputLabel.Text += secondArray[ i ] + " "; 83 84 // test whether reference was changed by SecondDouble 85 if ( secondArray == secondArrayCopy ) 86 outputLabel.Text += 87 "nnThe references refer to the same arrayn"; 88 else 89 outputLabel.Text += 90 "nnThe references refer to different arraysn"; 91 92 } // end method showOutputButton_Click 93 94 // modify elements of array and attempt to modify 95 // reference 96 void FirstDouble( int[] array ) 97 { 98 // double each element's value 99 for ( int i = 0; i < array.Length; i++ ) 100 array[ i ] *= 2; 101 Fig. 7.9 Passing an array reference by value and by reference (Part 2 of 3.).
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

Leave a Reply