It is important to eat a balanced diet with plenty of good quality protein (from tofu, quorn, cheese, pulses like lentils and beans and from nuts and seeds). The carbs you eat should be wholegrain as far as possible. Try to include both protein and carbs in your meals. Snack regularly as this will help you gain some weight but will not fill you up too much. Nuts and seeds are great to snack on.
Also do eat fruit and vegetables but not too much otherwise they will fill you up too much with defeats the object of what you are trying to do.
At the gym don't do any cardio. Just do the weights machines, free weights and floor work.
Good luck!