Let x be the oxidation number of Mg in Mg3–––––N2.
Since the overall charge on the compound is 0, the sum of oxidation states of all elements in it should be equal to 0.
Therefore, 3x+2(−3)=0
or, x=+2
Hence, the oxidation number of Mg in Mg––––3N2 is +2.