Ipower web hosting - 254 Arrays Chapter 7 // Fig. 7.9: ArrayReferenceTest.cs
Friday, September 7th, 2007254 Arrays Chapter 7 // Fig. 7.9: ArrayReferenceTest.cs // Testing the effects of passing array references // by value and by reference. using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; public class ArrayReferenceTest : System.Windows.Forms.Form { private System.Windows.Forms.Label outputLabel; private System.Windows.Forms.Button showOutputButton; [STAThread] static void Main() { Application.Run( new ArrayReferenceTest() ); } private void showOutputButton_Click( object sender, System.EventArgs e ) { // create and initialize firstArray int[] firstArray = { 1, 2, 3 }; // copy firstArray reference int[] firstArrayCopy = firstArray; outputLabel.Text = “Test passing firstArray reference by value”; outputLabel.Text += “nnContents of firstArray ” + “before calling FirstDouble:nt”; // print contents of firstArray for ( int i = 0; i < firstArray.Length; i++ ) outputLabel.Text += firstArray[ i ] + " "; // pass reference firstArray by value to FirstDouble FirstDouble( firstArray ); outputLabel.Text += "nnContents of firstArray after " + "calling FirstDoublent"; // print contents of firstArray for ( int i = 0; i < firstArray.Length; i++ ) outputLabel.Text += firstArray[ i ] + " "; Fig. 7.9 Passing an array reference by value and by reference (Part 1 of 3.).
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.