Suppose that $X$ is a zero mean random element with values in a separable Hilbert space $\mathbb H$ such that $\operatorname E\|X\|^2<\infty$. The covariance operator $C:\mathbb H\to\mathbb H$ of $X$ is defined as $C(f)=\operatorname E[\langle X,f\rangle X]$ for each $f\in\mathbb H$. I would like to show that $$ \langle C(f),f\rangle=\operatorname E|\langle X,f\rangle|^2 $$ for each $f\in\mathbb H$. I would like to proceed in the following way $$ \langle C(f),f\rangle=\langle \operatorname E[\langle X,f\rangle X],f\rangle=\operatorname E\langle \langle X,f\rangle X,f\rangle=\operatorname E[\langle X,f\rangle\langle X,f\rangle]=\operatorname E|\langle X,f\rangle|^2. $$ However, I do not know how I can justify taking the expectation out of the inner product. If I investigate a particular Hilbert space, for example, $L^2([0,1],\mathbb R)$, then I can use Fubini's theorem to justify the interchange of the order of integration, but how can I do that in the general case? Is it possible to justify taking the expectation out of the inner product in the general case?
Thank you very much for your help!
Too long for a comment, but not a complete answer by any means.
Additionally, I don't know the answer to this question, but I have some suggestions that you could perhaps consider.
Anyway, I hope that these points may be of some help to you. Sorry that I can't be of more help!