A current carrying closely wound solenoid acts like bar magnet. Each of the turn provide a dip’ole moment and all turns together provides the dipole moment of the magnet. Total magnetic moment,