I’m not sure if it was your question. I’m suggesting two approaches:
- Interfaces
- Generic classes
Interfaces
public interface IVehicle {
float Speed {get;}
void Move(float acceleration);
}
All your classes that enherits from an interface must the interface’s methods and properties.
public class Car : IVehicle {
private float _speed;
float Speed {
get => _speed;
}
void Move(float acceleration) {
speed += acceleration * time;
}
}
Generic classes
public class List<T> { }
Allows you to use any class instead of ‘T’.
Miceosoft Documentation Generic Classes