Integrate the LHS and the RHS of the pointwise identity $$ X=\int_0^X\mathrm dx=\int_0^\infty\mathbf 1_{X\geqslant x}\,\mathrm dx. $$ This shows that the desired formula for $E[X]$ holds irrespectively of the hypothesis that $X$ is discrete or continuous or neither discrete nor continuous, as soon as $X\geqslant0$ almost surely, and that two formulas are available, namely, $$ E[X]=\int_0^\infty P[X\geqslant x]\,\mathrm dx=\int_0^\infty P[X\gt x]\,\mathrm dx.$$