Example 2 (2004 National High School Competition Question) Let the three-digit number be $n=\overline{a b c}$, if the lengths of the sides of a triangle can be formed by $a, b, c$ to constitute an isosceles (including equilateral) triangle, then the number of such three-digit numbers $n$ is ( ).
A. 45
B. 81
C. 165
D. 216