The amount of food you eat is going to be the most important factor in helping you gain weight, but the quality of your choices is also worth paying attention to.
Eating a crappy diet is not only going to make you feel a little run down but can also affect your workouts, promote more fat gain than muscle, and cause potential health problems down the road.
Instead of eating whatever you want, aim to eat clean by opting for more healthy foods made with simple ingredients you recognize and cut down on heavily processed foods. Whole foods tend to be rich in the nutrients you need to thrive (aka vitamins and minerals).
They can also help you recover from workouts faster, build muscle, and promote a better mood, energy level, and overall health in general.
However, this doesn't mean you have to eat perfect 100% of the time - it's about consistency and overall balance.
Not to mention, when calorie needs are high, it can be challenging to stick to only filling, whole foods. In this case, adding more refined carbs and quick sources of energy can help. This is also where high-fat and energy-dense foods come into play.