7
Answers

Call another class's method from a different class, help

Moose Pickard

Moose Pickard

14y
2.1k
1
Hi,
me again

I want to call a method from another class.

I have

class Collection {
private List<Car>Cars = new List<Car>();
        public void remove(Car car) {
        Cars.Remove(car);
        }
}

class RentedCar {
        public void ReturnCar(Car car) {
        Collection.Cars.Remove(car;
        }
}

I want to use  Collection class method remove in RentedCar class. How do I do this?

Answers (7)