Magnesium is an element with atomic number 12. This means that every magnesium atom will have 12 protons.
In a magnesium atom, there are 12 electrons, to make the atom have a neutral charge. When an ion is formed, the magnesium atom loses electrons. The 2+ charge shows that the magnesium ion has two more protons than electrons. The proton number for magnesium does not change, so "Mg"^(2+) must have two less electrons, i.e. 10 electrons.
The number of neutrons varies among different isotopes of magnesium. An isotope of an element means it just has different amounts of neutrons.
The most common isotope of magnesium is ""^24"Mg". This 24 indicates the total number of protons and neutrons. Magnesium has 12 protons, so must have
24 - 12 = "12 neutrons"
Other isotopes of magnesium have different numbers of neutrons, i.e. ""^25"Mg" has 13 neutrons, ""^26"Mg" has 14 neutrons. ""^24"Mg" is most likely being referred to in the question, though.
I hope this helped!