public static void SetEngineCapacity(Vehicles io_Vehicle) { int engineCapacity; System.Type vehicleType = io_Vehicle.GetType(); PropertyInfo propertyInfo = vehicleType.GetProperty("EngineCapacity"); if (propertyInfo != null) { engineCapacity = GarageUI.GetEngineCapacity(); propertyInfo.SetValue(io_Vehicle, engineCapacity, null); } }