While cycling is primarily powered by your legs, your entire body is involved in the exercise. Poor bike fit, improper tire inflation and handlebar placement may cause hand pain or numbness in your fingers, whether it's a regular bike or a bike in an indoor class. Make sure your bike is properly fitted in terms of both seat height and pitch as well as handlebar setting to avoid this condition.
Median Nerve Pain
You can feel pain in any of the fingers of the hand, but the cause of the issue varies depending on which fingers are involved. If it's the thumb and first two fingers, you're sitting with your wrists bent for too long a period, causing the median nerve to be irritated and inflamed, which can cause pain, numbness or both. This is likely due to misplacement of your handlebars -- they're likely too low. Raise the handlebars up to see if the makes the pain go away.
Ulnar Nerve Pain
If the fourth and fifth finger -- the ring and pinkie -- are feeling numb or painful, then you're irritating the ulnar nerve. The ulnar nerve is in the palm pad on your hand. You're likely resting too heavily on your hands when you're riding. You've either developed a bad habit, or your brakes and gears may not be too far away. Try angling the handlebars up by rotating them slightly and angling your seat up and away from the handlebars. Also move your seat back to bear more weight in the saddle and not on your hands.
You may also have overinflated your tires. If your tires are above 100 psi and you're relatively lighweight -- under 120 lbs. -- lower the pressure in your tires. This should smooth the ride and lead to increased shock absorption by your tires rather than through your wrists and hands. In addition, you can buy softer tape to wrap around your handlebars, cushioning them more fully.
If you experience pain when you ride, have a proper bike fitting done by a professional and repeat the fitting if you've recently had a crash. A proper bike fitting is more than the length of your foot from the saddle. It also looks at saddle position, handlebar position, your body alignment when on the bike and access to gears and brakes. While a bike shop can provide this assistance, you an also request help from a physical therapist or physician who specializes in sports medicine.