The pattern of the magnetic field lines around a current carrying solenoid and a bar magnet are similar. One end of solenoid behaves as a magnetic north pole, while the other behave as the south pole that’s why solenoid behaves like a magnet.
The force experienced by a current carrying conductor placed in a magnetic field is largest when the direction of current is at right angles to the direction of magnetic field.