Weight gain is primarily caused by refined carbohydrates. So there's two ways to avoid them: 1) eat non-refined carbs like fruits, vegetables, and whole grains, or 2) restrict carbohydrates in general.
In my opinion, there is really no need to directly restrict carbohydrates. if you stick to fruits and vegetables, the fiber they contain will naturally limit carb consumption and also digest slowly.
In sum, stick to fruits and vegetables for carbs and don't worry about counting carb grams.