For-loop Array in C#

In this article I will explain that how to create for-loop Array.
  • 3672

Sometimes it is use the for-loop  on your arrays. the for loop is a very popular and useful loop construct.you will need to cast the element after using its index.You can find more separate information on indexers here.

namespace demo_array
{
    class Program
    {     
        static void Main(string[] args)
        {
            int[] array = { 100, 300, 500, 700, 900, 1000 };
            // Use for loop.
            for (int i = 0; i < array.Length; i++)
            {
                    Console.WriteLine(array[i]);
           }
            Console.ReadKey();
        }
   }
}

 Output 

forloop array.jpg

Ask Your Question  

Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.