5. If the function $f(x)$ satisfies for $x \in \mathbf{R}$: $f(x+999)=-\frac{1}{f(x)}, f(999+x)=f(999-x)$, then $f(x)$
A. is an odd function but not an even function
B. is an even function but not an odd function
C. is both an odd function and an even function
D. is neither an odd function nor an even function
5. B From $f(x+999)=-\frac{1}{f(x)}$ we get $f(x+1998)=-\frac{1}{f(x+999)}$, which means $f(1998+x)=f(x)$, so $y=$ $f(x)$ is a periodic function with a period of 1998,
because $f(x)=f(1998+x)=f[999+(999+x)]$
$$
=f[999-(999+x)]=f(-x) \text {. }
$$

That is, $f(-x)=f(x)$, so $y=f(x)$ is an even function. Therefore, the answer is B.