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
Solution: Choose C. Reason: For $a, b, c$ to form the sides of a triangle, they obviously cannot be zero, i.e., $a, b, c \in\{1, 2, 3, \cdots, 9\}$.
(1) If they form an equilateral triangle, then $a=b=c$ can take any value from $\{1, 2, \cdots, 9\}$, so the number of such three-digit numbers is $n_{1}=C_{9}^{1}=9$.
(2) If they form an isosceles (non-equilateral) triangle, let the number of such triangles be $n_{2}$, and the three sides of the isosceles triangle be $a_{1}, b_{1}=c_{1}$. When $a_{1} < b_{1}=c_{1}$, i.e., the legs are less than the base, the pairs $\left(a_{1}, b_{1}\right)$ have $C_{9}^{2}$ possibilities, but they must satisfy $b_{1}<a_{1}<2 b_{1}$ to form a triangle. The pairs $\left(a_{1}, b_{1}\right)$ that cannot form a triangle are:
\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|}
\hline$a_{1}$ & 9 & 8 & 7 & 6 & 5 & 4 & 3 & 2 & 1 \\
\hline$b_{1}$ & $1,2,3,4$ & $1,2,3,4$ & $1,2,3$ & $1,2,3$ & 1,2 & 1,2 & 1 & 1 & \\
\hline
\end{tabular}

There are a total of 20 such cases, so the number of isosceles (non-equilateral) triangles is $C_{9}^{2}-20$. Each pair $\left(a_{1}, b_{1}\right)$ can form $C_{3}^{2}$ three-digit numbers $\overline{a b c}$, so $n_{2}=C_{3}^{2}\left(C_{9}^{2}-20\right)=156$. In summary, $n=n_{1}+n_{2}=165$, hence the answer is C.