Set array element value by index(subscript) : Array Index « Data Structure « C# / CSharp Tutorial






using System; 
 
class MainClass {  
  public static void Main() {  
    int[] nums = new int[10]; 
    int avg = 0; 
 
    nums[0] = 99; 
    nums[1] = 10; 
    nums[2] = 100; 
    nums[3] = 18; 
    nums[4] = 78; 
    nums[5] = 23; 
    nums[6] = 63; 
    nums[7] = 9; 
    nums[8] = 87; 
    nums[9] = 49; 
 
    for(int i=0; i < 10; i++)  
      avg = avg + nums[i]; 
 
    avg = avg / 10; 
 
    Console.WriteLine("Average: " + avg); 
  }  
}
Average: 53








11.2.Array Index
11.2.1.Set array element value by index(subscript)
11.2.2.Demonstrate an array overrun
11.2.3.Assigning array reference variables
11.2.4.Use the IndexOf() and LastIndexOf() methods to find the value 1 in intArray
11.2.5.Use the IndexOf() and LastIndexOf() methods to find the string 'Hello' in stringArray
11.2.6.Swapping Data between Positions in an Array