public static Weapon GetWeapons(Hero fightingHero) { var serviceProvider3 = DIConfiguration.ConfigurazioneWeapon(); WeaponService weaponService = serviceProvider3.GetService <WeaponService>(); Console.WriteLine("Le armi a tua disposizione sono:"); weapon: //List<Weapon> weapons = new List<Weapon>; var weapons = weaponService.GetAllWeapons(fightingHero); for (int i = 0; i < weapons.Count(); i++) { Console.WriteLine("{0} - {1}", i, weapons[i].name); } Console.WriteLine("Inserisci il numero dell'arma che hai scelto:"); try { int index = Convert.ToInt32(Console.ReadLine()); Weapon w = weapons[index]; Console.WriteLine("Il tuo personaggio è un {0} di nome {1} la cui arma è {2}", fightingHero.classPerson, fightingHero.name, w.name); return(w); } catch (Exception e) { Console.WriteLine("Inserimento non valido"); goto weapon; } }