It was narrated that 'Abdullah said: "We went out with the Messenger of Allah and we were young men who could not afford anything. He said: “O young men, you should get married, for it is more effective in lowering the gaze and protecting one's chastity. Whoever cannot afford it should fast, for it will be a restraint Wija, for him”"
SahihSahihSahih - Agreed UponBook 22 · Hadith 150