Вывести в void main список - C#
Формулировка задачи:
Как мне вывести в void main список, так что бы при нажатие 1 выводило Танки, при нажатие 2 выводило самолеты
public class Catalog
{
public static int Tank()
{
List<Weapon_Base> Tank = new List<Weapon_Base>();
Tank.Add(new Weapon_Base() { Name = "T32", Country = "Америка", Gun = "90 мм", Course = "7.62 мм" });
Tank.Add(new Weapon_Base() { Name = "ИС-2", Country = "CCCH", Gun = "122 мм", Course = "13 мм" });
Tank.Add(new Weapon_Base() { Name = "Tiger II (H)", Country = "Германия", Gun = "108", Course = "7.62 мм" });
return 0;
for (int i = 0; i < Tank.Count; i++)
{
Console.WriteLine(Tank[i].Name);
Console.WriteLine(Tank[i].Country);
Console.WriteLine(Tank[i].Gun);
Console.WriteLine(Tank[i].Course);
}
}
public static int Plane()
{
List<Weapon_Base> Plane = new List<Weapon_Base>();
Plane.Add(new Weapon_Base() { Name = "F6F BirdCat", Country = "Америка", Gun = "12.4 мм", Course = "Отсутствует" });
Plane.Add(new Weapon_Base() { Name = "ЯК-9Т", Country = "СССР", Gun = "12.4 мм/7.62 мм", Course = "Отсутствует" });
Plane.Add(new Weapon_Base() { Name = "Bf.109c", Country = "Германия", Gun = "20 мм", Course = "Отсутствует" });
return 0;
for (int i = 0; i < Plane.Count; i++)
{
Console.WriteLine(Plane[i].Name);
Console.WriteLine(Plane[i].Country);
Console.WriteLine(Plane[i].Gun);
Console.WriteLine(Plane[i].Course);
}
}
}
static void Main(string[] args)
{
int menu;
Console.WriteLine("Нажмите 1 что выбрать танки");
Console.WriteLine("Нажмите 2 что выбрать самолеты");
menu = int.Parse(Console.ReadLine());
if (menu == 1)
Catalog.Tank();
if (menu == 2)
Catalog.Plane();
Console.Read();
}
}Решение задачи: «Вывести в void main список»
textual
Листинг программы
return 0;