Let $H$ be a separable, infinite dimensional Hilbert space. I wish to show that for projections $p,q\in B(H)$, then $p\sim q$ if and only if $dim(pH)=dim(qH)$. Note that $p\sim q$ means that there exists an element $v\in B(H)$ such that $p=v^*v$ and $q=vv^*$.
Now I don't know how to do this, but it is because I haven't figured out how to generalized my idea when $H=\mathbb{C^n}$. If this is the case, then a projection over $\mathbb{C^n}$ is given by a matrix and this matrix will be diagonalizable. Since the only eigenvalues of $p$ are $0$ or $1$, then the trace of $p$ will precisely be the number of times $1$ appears on the diagonal, which is the same as its dimension. Hence if $p\sim q$, then they have the same trace so they have the same dimension. The other direction I am not sure.
The problem I encounter is that when $H$ is infinite dimensional, separable, then these "matrices" that represent $p$ are "infinite matrices", but this isn't rigorous. Could someone please help me with a hint or solution?
Edit: With the comment from Mike F., I have shown that $v:pH\to qH$ is a hilbert space isomorphism, which implies dim(p)=dim(q).
Conversely, supposing that dim(p)=dim(q), take $\{e_i\}_{i\in I}$ as ONB for pH and $\{f_i\}_{i\in I}$ as ONB for qH.
We can define a map $v$ from the span of $\{e_i\}$ via $\sum_{i\in I}\lambda_i e_i\mapsto \sum_{i\in I}\lambda_i f_i$. whenever the element in the span is norm convergent. Since $v$ is linear, continuous and the span of $\{e_i\}$ is dense in pH, $v$ should extend to a unique, continuous operator from $v:pH\to qH$.
Here is where I get confused. I know that I need to extend $v$ again as an operator in $B(H)$ such that $v^*v=p$ and $vv^*=q$, but I am not sure how to do this. I also need $v$ to be an isometry from $pH$ and $qH$, i.e. for all $x,y\in pH$, $<x,y>=<vx,vy>$. My issue with showing that claim in particular is the somewhat vague description of an adjoint operator and the fact that I am not sure how $v$ and $v^*$ "look like" on elements that aren't in the span of their respective ONB that I listed earlier.