5. Let the three-digit number $n=abc$. If $a$, $b$, and $c$ can form an isosceles (including equilateral) triangle, then the number of such three-digit numbers is ( ) .
(A) 45
(B) 81
(C) 165
(D) 216
5. C.

According to the problem, there are 9 equilateral triangles, and there are $3 \times(8+8+8+8+8+6+4+2)$ $=156$ isosceles but not equilateral triangles.
Therefore, the answer is $9+156=165$.