Example 2 Let $X_{n}=\{1,2, \cdots, n\}$. Find $\sum_{A \subseteq X_{n}} S(A)$, where $S(A)$ denotes the sum of all elements in $A$, and $S(\varnothing)=0$.
Let $A=\left\{a_{1}, a_{2}, \cdots, a_{t}\right\}$ be any subset of $X_{n}$, then $S(A)=a_{1}+a_{2}+\cdots+a_{t}$. Hence,
$$
\sum_{A \subseteq X_{n}} S(A)=\sum_{\left\{a_{1}, a_{2}, \cdots, a_{t} \subseteq X_{n}\right\}}\left(a_{1}+a_{2}+\cdots+a_{t}\right) \text {. }
$$

Consider the number of times $i(i=1,2, \cdots, n)$ appears in the above sum. Since there are $2^{n-1}$ subsets of $X_{n}$ that contain $i$, $i$ is counted $2^{n-1}$ times in the sum. Therefore,
$$
\begin{array}{l}
\sum_{A \subseteq X_{n}} S(A)=\sum_{\left\{a_{1}, a_{2}, \cdots, a_{t} \subseteq X_{n}\right\}}\left(a_{1}+a_{2}+\cdots+a_{t}\right) \\
=\sum_{i=1}^{n} i \times 2^{n-1}=n(n+1) 2^{n-2} .
\end{array}
$$