Anisotropy is an important feature of the layered material, at which a large anisotropy is usually related to the two dimensional characteristics. We investigated the anisotropy of the layered transition metal dicalcogenide 2$H$-NbSe$_2$ at the superconducting and charge density wave (CDW) states by using magnetotransport measurements. In the superconducting state, the normalized $H_{\mathrm{c2}}^{||c}/H_p$ is independent of the thickness of 2$H$-NbSe$_2$, while $H_{\mathrm{c2}}^{||ab}/H_p$ increases significantly with decreasing the thickness, where $H_p$ is the Pauli limiting magnetic field, and $H_{\mathrm{c2}}^{||c}$ and $H_{\mathrm{c2}}^{||ab}$ are the upper critical field at $c$ and $ab$ directions, respectively. It is found that the superconducting anisotropy parameter $\gamma_{Hc2}=H_{\mathrm{c2}}^{||ab}/H_{\mathrm{c2}}^{||c}$ increases with reducing the thickness of 2$H$-NbSe$_2$. %from 4.65 in the bulk sample to 17.7 in the ultrathin sample ($5-10$ layers). In the CDW state, the angular ($\theta$) dependent of magnetoresistance $R(H,\theta)$ scales with $H(\cos^2\theta+\gamma_{CDW}^{-2}\sin^2\theta)^{1/2}$, which decreases with increasing the temperature and disappears at about 40 K. It is found that the CDW anisotropy parameter $\gamma_{CDW}$ is much larger than the effective mass anisotropy but does not change a lot for the ultrathin and bulk samples. Our results suggest the three-dimensional superconductivity and quasi-two dimensional CDW in the bulk 2$H$-NbSe$_2$.