5. If $(x+1)(y+1)=x^{2} y+x y^{2}=6$, then, $x^{2}+y^{2}$ equals $(\quad)$.
(A) 6
(B) 5
(C) 4
(D) 3
5.B.

From $\left\{\begin{array}{l}x y+(x+y)=5, \\ x y(x+y)=6,\end{array}\right.$ we get $\left\{\begin{array}{l}x+y=3, \\ x y=2\end{array}\right.$ or $\left\{\begin{array}{l}x+y=2, \\ x y=3\end{array}\right.$ (discard). Therefore, $x^{2}+y^{2}=(x+y)^{2}-2 x y=9-4=5$.