Q:

Inputing a selection from an array c#

Hi there I'm very new to C# so please bear with me if my question has a very obvious answer.
I am trying to write a code that displays an array of options to the user with a number to select the option. The user then selects their option and the code will display their selection from the array. 
So for example 
Select 1 for apples
Select 2 for oranges
Select 3 for pears

Please Enter your Selection :

I keep typing a for loop to display my area but I cannot get my program to read the input from the array this is what I have so far 
static void Main(string[] args) {

  string[] fruit = [3]

  fruit[0]=("apples");
  fruit[1]=("oranges");
  fruit[2]=("pears");

  for (int i = 0; i < fruit.length; i++)
  {
    Console.WriteLine("Enter {0} to select {1}", i, fruit[i]);
  }

  string choice = Console.ReadLine();
  int i = int.Parse(choice);
  Console.WriteLine("You have selected {0} which is {1}", i, fruit[i]);
  Console.ReadLine();
}

This gives me an error and if I place this within the for loop then the program does not display me all my options.

A:

Multiple problems with your code:

Define your string array like string[] fruit = new string[3];
Since you have defined i in your for loop, you need to use a new variable for your input. 
Your condition in for loop should be i < fruit.Length
This is more of a suggestion, use int.TryParse to parse input from console, check if the entered number is an int and also check if the number is less than the array length. 

A:

You need to give different name to your loop variable or the user choice.
Also you might want to use TryParse intead of Parse to prevent possible FormatExceptions:
int userChoice;
if(int.TryParse(choice, out userChoice) && userChoice < fruit.Length)
      Console.WriteLine("You have selected {0} which is {1}", userChoice, fruit[userChoice]);

