static void Main(string[] args) { int choice; vehicle v_obj = new vehicle(); Console.Write("List of Vehicles \n1.Car \n2.Bike \n3.Truck \n4.Bus"); Console.Write("\nEnter your Choice: "); choice = int.Parse(Console.ReadLine()); if (choice == 1) { v_obj.choi = choice; vehicle.Field(v_obj); } else if (choice == 2) { v_obj.choi = choice; vehicle.Field(v_obj); } else if (choice == 3) { v_obj.choi = choice; vehicle.Field(v_obj); } else if (choice == 4) { v_obj.choi = choice; vehicle.Field(v_obj); } else { Console.WriteLine("\nInvalid Input "); } Console.ReadKey(); }
public static void Field(vehicle v) { switch (v.get_choice) { case 1: Console.WriteLine(car); break; case 2: Console.WriteLine(bike); break; case 3: Console.WriteLine(truck); break; case 4: Console.WriteLine(bus); break; } }