well, if u start pounding down twinkies and burger king all day, you could work out as much as you want and still get fat. U gain weight obviously by consuming more calories than you burn off in the course of ur days. You wanna eat low fat , high protein foods, ( tuna, chicken, lean meats, fish, protein bars\shakes, egg whites , etc). You wanna eat enough of that sort of thing, in order to gain no more than 7 -8 pounds a month. Any more weight than that, and your most likely putting on more fat , than lean muscle mass. But you cant expect to gain 20 pounds of muscle with out putting on any fat. But, its easier to shave off 5 pounds of fat, than it is to build 20 pounds of muscle.
Also, just eating right wont make you build muscle, you gotta be hitting those weights.
Just all depends on your goals. If you wanna lose weight, get a nice lean diet of high protein , low fat foods, and do a lil cardio, the pounds should fly off. But, if you wanna bulk up, you gotta eat enough food to make you gain weight, and you gotta be sculpting that weight by working out.
My advice, for either, is first you must count how many calories you eat in a given day. Then, if you wanna gain weight add about 400 calories a day, if you wanna loose weight , you wanna decrese by 400 a day. Either way, no more then 1-2 lbs gains a week, or vice versa. Hope some of my rambling helped