When you're trying to gain the right kind of weight (muscle as opposed to fat) you want to eat healthy foods and a lot of them. You need all three types of calories: carbohydrates, protein and yes, even fat.
Carbohydrates are your main source of energy and you want around 50% of your daily intake to come from them. There are two types of carbs: simple and complex. Simple carbs are sugars which can be found in soda, candy, chocolate and fruit. Complex carbs are found in bread, rice, pasta and vegetables.
Simple carbs are digested quickly and can be used in a post workout meal to get nutrients to your muscles quickly. The rest of the day you should be eating complex carbs which will give you a slower energy release throughout the day. They're digested slower and will help you keep your body fat percentage low.
There's a misconception that eating fat makes you fat. About 30% of your calories should come from fat. Saturated (bad, unhealthy) fats should account for no more than 10% and the remaining 20% should come from unsaturated (good, healthy) fats. Unsaturated fat is found in oils, vegetables and any other non-animal source (vegetable spreads).
Saturated fat is found in any food that comes out of an animal: dairy, meat, eggs. Stay away from trans fatty acids. These are basically a man made fat found in any food that contains hydrogenated oils (check the ingredients).
The rest of your calories should come from protein. Protein is either complete or incomplete. If its complete, your body can use it to build muscles. If its incomplete your body will need to combine it with another protein to make a complete one or some of it won't be used.
Complete sources of protein come from animal sources and incomplete ones come from vegetables. Try getting your protein from lean sources of meat (poultry, fish, lean cuts of beef) and low fat dairy. You don't want all that saturated fat clogging your arteries.
Vegetarians can get complete proteins by eating a wide variety of foods and through supplementation. Legumes (nuts, peas, beans) are an excellent source for those who don't eat meat.
Vitamins and Minerals
A lot of people who are bulking up tend to forget about their vitamins and minerals. Some take a multivitamin and others ignore them all together. Eating your fruits and vegetables is very important. Even though they are very low in calories, they are high in nutrients which will help your body better metabolize all the calories you're taking in.
The Bottom Line
In order to gain weight, you must consume more calories than you burn. Eating everything in sight, as many would recommend, leads to unsighlty weight rather than the mass you're most likely looking for.