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] + " ");
       }
     }
}
 

What is Rectangular Array With Example Code

A rectangular array is a two-dimensional array where each row has an equal number of columns.

 Syntax:

       type [,]<variableName>;
       variableName = new type[value1 , value2];
 
 where,
     
      type: Specifies the data type of the arrays element.
     
      [,]: Specifies that the array is a two-dimensional array.
   
      variableName: Specifies the name of the two-dimensional array.

      new: Is the operator used to instantiate the arrays.

      value1: Specifies the number of rows in the two-dimensional array.

      value2: Specifies the number of columns in the two-dimensional array.

 Example 3:

 using System;
 class StudentScore
 {

          void StudentDetails()
         
          {
           
               Console.Write("Enter the number of Students: ");
               int noOfStds = Convert.ToInt32(Console.ReadLine());
               Console.Write("Enter the number of Exams: ");
               int exams = Convert.ToInt32(Console.ReadLine());
               string[] stdName = new string[noOfStds];
               string[,] details = new string[noOfStds, exams];
               for (int i = 0; i < noOfStds; i++)
              
               {
                    Console.WriteLine();
                    Console.Write("Enter the Student Name: ");
                    stdName[i] = Convert.ToString(Console.ReadLine());
                    for (int y = 0; y < exams; y++)
                    {

                         Console.Write("Enter Score in Exams " + (y + 1) + ": ");
                         details[i, y] = Convert.ToString(Console.ReadLine());

                    }
               }             
              
               Console.WriteLine();
               Console.WriteLine("Student Exam Details");
               Console.WriteLine("--------------------");
               Console.WriteLine();
               Console.WriteLine("Student\t\tMarks");
               Console.WriteLine("-----\t\t------");                  
               for (int i = 0; i < stdName.Length; i++)
               {
                    Console.WriteLine(stdName[i]);
                    for (int j = 0; j< exams; j++)
                    {
                         Console.WriteLine("\t\t" + details[i, j]);
                    
                    }
                    Console.WriteLine();
 
               }
            }
            static void Main()
            {

                StudentsScore objStudentsScore = new StudentsScore();
                objStudentsScore.StudentDetails();

            }
 }

Jagged Array Description With Code Example

 A jagged array can be defined as an arrays. The length of individual arrays of a jagged array need not be the same. Jagged arrays can be used to create tables having rows of different lengths.

A jagged array is declared using square brackets([])that indicate a single dimension.

 Example 4:

 using System;
 class Sports
 {
    
         static void Main(string[] args)
         {

                string[] atheleteNames = new string[] { "Alton White","Mary Cruz","Susan Dias" };
                string[][] events = new string[3][];
                events[0] = new string[] { "100 Mts Sprint", "200 Mts Sprint", "High Jump", "Relay" };
                events[1] = new string[] { "Tripple Jump", "Hurdles", "Long Jump" };
                events[2] = new string[] { "200 Mts Sprint", "High Jump" };
                Console.WriteLine("Participants\tEvents");
                for (int i = 0; i < events.GetLength(0); i++)
                {

                     Console.Write("{0} \t",atheleteNames[i]);
                     for (int j = 0; j < events[i].GetLength(0); j++)
                     {

                          Console.Write("[{0}] ",events[i][j]);
                       
                     }
                     Console.WriteLine();
                }

          }
 }