The question is as follows:
Let $W$ be Brownian motion and $T$ a stopping time with $\mathbb{E} T < ∞$. Show (use stochastic integrals) that $\mathbb{E}W_T = 0$ and $\mathbb{E} W^2_T = \mathbb{E} T$.
Now, I have showed this result before (it was somewhere along these lines: Dominated convergence problems with Wald's identity for the Brownian Motion), but that proof did not include stochastic integrals and I do not see where it would come in handy.
At first, I figured that we have $W_t = \int_0^t \text{ d}W_s$ for any $t\geq0$, so the equality will also hold when we plug in a stopping time $T$. However, then we have $$ \mathbb{E}W_T = \mathbb{E}\int_0^T 1 \text{ d}W_s, $$ but we cannot swap integral and expectation here. Does anyone have an idea where we could use stochastic integrals in a meaningful way in this proof?