Code not working.

rei

New member
Joined
Sep 2, 2015
Messages
4
Programming Experience
Beginner
using System; namespace C_Sharp_Practice { class MainClass { public static void Main (string[] args) { string[] FavoriteFoods = new string[5]; FavoriteFoods[0] = "Apples"; FavoriteFoods[1] = "Carrots"; FavoriteFoods[2] = "Steak"; FavoriteFoods[3] = "Pizza"; FavoriteFoods[4] = "Spahgetti"; Console.WriteLine(FavoriteFoods.Length); } public void ListFoods() { int i = 0; while (i < FavoriteFoods.Length) { i = i + 1; Console.WriteLine(FavoriteFoods); } } } } ///I'm kinda new to C#. I'm thinking that my 'ListFoods' method doesn't have access to the contents of my 'Main' method. Anyone know what's the problem?
 
Last edited:
Your code is virtually unreadable as it is. Please copy it from VS as plain text and paste it into appropriate formatting tags, i.e.

[xcode=c#]your code here[/xcode]

Also, please provide a meaningful title for threads in future. Pretty much everyone who posts has code that doesn't work so it means nothing to us. Also, please provide a FULL and CLEAR description of the issue. That would include explaining what you expect to happen and what actually does happen, including any error messages.
 
Back
Top Bottom