I put two steel rods side by side inside a solenoid. Then I flicked the switch.
The rods repelled because the magnetic field of the solenoid lines up the domains in the steel. This turns both steel rods into magnets. The domains are aligned identically in each rod so they both have north poles at the same end so they repel.