Magnetic field lines can be entirely confined within the core of a toroid but not within a straight solenoid. since no two magnetic field lines can intersect, and they are originating and ending at the same point (as it is in a ring) thus they are confined to the core of toroid.