Check Page Rank of your Web site pages instantly:

What Is The Defination Of Array References Variable With Example

An array variable can be referenced by another array variable (referringvariable). While referring, the
referring array variable refers to the values of the referenced array variable.

Example 2 demonstrates the use of array references.

Example 2:

using System;
class StudentReferences

{
  
    public static void Main()

    {

       string[] classOne = { "Allan", "Chris", "Monica" };
       string[] classTwo = { "Katie", "Niel", "Mark" };
       Console.WriteLine("Students of Class I:\tStudents of Class II");
      
       for (int i = 0; i < 3; i++)
      
       {
           Console.WriteLine(classOne[i] + "\t\t\t" +  classTwo[i]);
   
       }
       
       classTwo = classOne;
       Console.WriteLine("\nStudents of Class II after referencing Class I:");
       for (int i = 0; i < 3; i++)
       {
           
          Console.WriteLine(classTwo[i] + " ");
     
       }
       Console.WriteLine();
       classTwo[2] = "Mike";
       Console.WriteLine("Students of Class I after changing the third student in Class II:");
       for (int i = 0; i < 3; i++)    
       {
    
           Console.WriteLine(classOne[i] + " ");
       }
     }
}
 

2 comments:

Post a Comment