Using the index operator in a simple array

static void Main(string[] args)
{
  // Loop over incoming command-line arguments
  // using index operator.
  for(int i = 0; i < args.Length; i++)
    Console.WriteLine("Args: {0}", args[i]);
 
  // Declare an array of local integers.
  int[] myInts = { 10, 9, 100, 432, 9874};
 
  // Use the index operator to access each element.
  for(int j = 0; j < myInts.Length; j++)
    Console.WriteLine("Index {0}  = {1} ", j,  myInts[j]);
  Console.ReadLine();
}

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.