The stability criteria of both the ideal and the resistive interchange modes are calculated varying the geometry of a plasma cross section for an axisymmetric toroidal magnetohydrodynamic equilibrium in a flux coordinate system. The effects on the stability of the geometric parameters, such as a shift, an ellipticity and a triangularity of the plasma cross section are considered. Also the effects of a shear and a magnetic well on the stability are considered. A combined effect of the magnetic well and an averaged toroidal curvature is the main stabilizing effect. The most stable geometry of the plasma cross section is a vertically elongated D-shape.