0
I am learning by the book Use the Head and in it there is the following code to do an exercise of random items
public class Menu
{
public Random Randomico;
string[] Carnes = { "Rosbife", "Salame", "Peru", "Presunto", "Pastrami" };
string[] Condimentos = { "Mostarda amarela", "Mostarda Marrom", "Mostarda com mel", "Maionese", "Molho Francês", "Gosto" };
string[] Paes = { "Centeio", "Branco", "Trigo", "Pão italiano", "Pão integral", "árabe" };
}
public string ItemMenu() {
string ramdonCarne = Carnes[Randomizer.Next(Carnes.Lenght)];
string ramdonCondimento = Condimentos[Randomizer.Next(Condimentos.Lenght)];
string ramdonPao = Paes[Randomizer.Next(Paes.Lenght)];
return ramdonCarne + "com " + ramdonCondimento + "no " + ramdonPao;
}
However, in Visual Studio, is giving error when creating the Itemmenu method, but the book does not inform anything about something unusual that may happen.
Could someone help me.
You’re right, man. I tidied it up here and it was straight. The main problem is that I am following an English workbook and translating at the same time, so the name of some variables are wrong, because I forget to translate. But the main error was that I left the method out of the class. Thanks a lot for the help, Maniero. Really worth it!
– Rafael Ventura