Catalysis of the reaction: a 2'-deoxycytidine in DNA + S-adenosyl-L-methionine = a 5-methyl-2'-deoxycytidine in DNA + H+ + S-adenosyl-L-homocysteine.
deoxyribonucleic (cytosine-5-)-methyltransferase activity