Write a C# program that should declare & initializes single dimension array of type string called colors. The program should display the output based on the following requirements.
•It should display an array size using length property.
•It should access each element in an array using for loop only.
Make sure to add comments in the code. The program should generate the output as given in below sample output.
Answer:
using System;
using System.Linq;
namespace Colors // name of project
{
class Colors // class name
{
static void Main(string[] args)
{
//initialize array colors as below
string[] colors = {"Red","White","Green","Pink","Yellow","Black"};
Console.WriteLine("The Length of an Array is {0}",colors.Length);
for (int t = 0; t
{
string element = colors[t]; //define element at index t
Console.WriteLine(element); // print array element
}