It is narrated from Sayyiduna Abdullah bin Mas'ud (may Allah be pleased with him) that the Messenger of Allah (peace and blessings be upon him) said: "O young men, hold fast to marriage, for it lowers the gaze more and guards the private parts better. Whoever is not able to do so should fast, for it will be like castration for him (in curbing desire)."
Hadith Referenceالمعجم الكبير للطبراني / باب العين / 9991