I'm stuck on an old algebra prelim problem. The problem is to prove that a nonabelian group of order $2p,p \text{ an odd prime}$ has trivial center. One thing I know is that any nonabelian group of order $2p,p>2$ is isomorphic to the dihedral group $D_{2p}$, but I think here we have to use the class equation
$$|G|= |Z(G)| + \sum_{i=1}^r [G: C_{G}(g_i)],$$ where the $g_i$ are the noncentral conjugacy classes of the group $G$, i.e. they are not in the center $Z(G)$. I haven't yet attempted it, but I think it boils down to assuming to the contrary that $|Z(G)| \neq 1$, and coming up with an argument that should lead to $p=2$. Not yet clear what that is, though. I would really appreciate some assistance here.