Statistical mechanics of electrolytes and polyelectrolytes. I. Symmetric electrolyte solutions