Well, you have to figure out how much you require in terms of calories.
First, figure that out by putting some numbers through a calorie calculator. This will give you a rough estimate about how many calories your body requires.
After that, you have to figure out how many calories you are eating per day at the moment. Most of the time, we are eating well under the amount required. To gain, weight you will have to eat more than 500 calories ABOVE the number given in the calculator.
Also, when gaining weight, don't just pig out. It's a very unhealthy way to go about things and can end up causing you a lot of harm. Eat healthy and eat a lot, but divide the calories up into small meals.