The mutual relationship between stacking and hydrogen-bonding and the possible influence of stacking in the different behavior of cytosine (C) and 5-methylcytosine (C') in DNA have been studied through complete DFT optimization of different structures of G-C and G-C' dimers (i.e., G-C/C-G and G-C'/C'-G), using four different functionals. Our results show that stacking leads to an increase of the O(6)...H-N(4) hydrogen bond length and to a simultaneous decrease of the N(2)-H...O(2) one, in such a way that both lengths approach each other and, in some cases, an inversion occurs. These results suggest that stacking can be a factor to explain the disparity between theory and experiment on the relative strength of the two lateral hydrogen bonds. Regarding the difference between cytosine and 5-methylcytosine, we have shown that methylation enhances the stacking interactions, mainly due to the increase of polarizability. Methylation also favors the existence of slid structures which can produce local distortions of DNA.