Example 1 The number of integer solutions to the equation $\frac{x+3}{x+1}-y=0$ is ( ) groups.
(A) 1
(B) 2
(C) 3
(D) 4
(2004, National Junior High School Mathematics Competition, Tianjin Preliminary Round)
From $\frac{x+3}{x+1}-y=0$, we know
$$
y=\frac{x+3}{x+1}=1+\frac{2}{x+1} \text{.}
$$

Since $x, y$ are both integers, therefore, $x+1= \pm 1$ or $\pm 2$.

Thus, $(x, y)$
$$
=(-2,-1),(0,3),(1,2),(-3,0) \text{.}
$$

Therefore, the original equation has 4 integer solutions.
Hence, the answer is D.