The correct option is B 2
Magnesium has 12 electrons and its electronic configuration can be written as 2,8,2. So there are 2 electrons in the outermost orbit of Magnesium, or we can say that Magnesium has two valence electrons.
Magnesium wants to give away these two valence electrons to its neighboring Chlorine atoms in MgCl2, so that Magnesium complete its octet by having eight electrons in its outermost orbit and by attaining the electronic configuration of its nearest inert gas Neon. After Magnesium gives away its two valence electrons it now has 10 electrons and hence its oxidation number becomes +2.