I was asked this question in an interview some twenty years ago. This is a typical Fermi problem. Solving it means making a good estimate with little data. Of course, there are many possible approaches; my answer went something like this…

Because

- the Sun makes almost all of the Solar System’s mass (more than 99%) and
- the Sun consists mostly of hydrogen (around three quarters is hydrogen and the rest is mostly helium; this is a good enough approximation)

the number of electrons roughly equals the mass of the Sun \(m_S\) divided by the mass of the hydrogen atom \(m_H\). But I didn’t know \(m_S\) and \(m_H\) off the top of my head, so I had to improvise.

Let’s start with \(m_H\).
The Avogadro number is much easier to memorize than the mass of the hydrogen atom—there are 6.0 · 10^{23} atoms in one gram of hydrogen.
Therefore

$$m_H \approx 2 \cdot 10^{-27} \, \mathrm{kg} .$$

The mass of the Sun was more challenging. My starting point was the gravitational force

$$F = G \frac{m_S m_E}{r^2}$$

between the Sun and Earth, which is also the centripetal force

$$F = m_E r \omega^2$$

that makes Earth circle around the Sun. To calculate the Sun’s mass, we only need the gravitational constant \(G\), the distance between the Sun and Earth \(r\), and the angular velocity \(\omega\):

$$m_S = \frac{r^3 \omega^2}{G} .$$

Luckily, back then I knew the value of the gravitational constant

$$G = 6.7 \cdot 10^{-11} \, \mathrm{m^3 kg^{-1} s^{-2}} .$$

Next, the angular velocity is 2π radians over 365 days, i.e.,

$$\omega = 2.0 \cdot 10^{-7} .$$

Also, it takes a little bit more than eight minutes for light to travel from the Sun to Earth at the speed of 3.0 · 10^{8} m/s, so

$$r = 1.5 \cdot 10^{11} \, \mathrm{m} .$$

Therefore

$$m_S \approx 2 \cdot 10^{30} \, \mathrm{kg} .$$

Finally, there are around 10^{57} electrons in the Solar System.