If $X$ is a metric space with infinitely many connected components, is $X$ compact? I am having trouble with the following question. Can anyone help?


*

*Suppose $(X ,d)$ is a  metric space which has infinitely many distinct connected components. Then is $X$ compact? 


Can anyone help me with a proof or a counterexample.

In fact, there is no link in general between the number of connected components and compacity. A compact space can have either infinitely many connected components (eg. Cantor set) or finitely many (eg. $[0,1] \cup [2,3] \cup ... \cup [2n,2n+1]$); a non compact space can have either infinitely many connected components (see Zev Chonoles' answer) or finitely many (eg. $\mathbb{R}^n$).
However, if your space $X$ is supposed to be locally connected, then the connected components of $X$  are open; therefore, if $X$ is compact, it has finitely many such components.
