It is said one should avoid staring at Sun as it can damage the eyes, but it is also said that one should not come out in sun during eclipse as it emits dangerous rays. Is that true? If yes, why?
There's certainly no problem being out in the Sun during an eclipse: There's nothing being emitted then that's not being emitted at other times. The danger is just that the relative darkness near totality may make it seem safe to look at the Sun, even when it's not. But as long as you don't look directly at the Sun, you're fine.
During the time when an eclipse is total, it is safe to look at it with the naked eye. But only during totality. Even when the eclipse is almost total -- a thin crescent or even just Bailey's beads or the diamond ring visible -- you can damage your eyes by looking at it. So if you're planning to view an eclipse, be sure you can identify totality before looking with the naked eye. Viewing with an experienced eclipse-watcher is a good idea if you can arrange it.
As Mr. Eclipse puts it
Permanent eye damage can result from looking at the disk of the Sun directly, or through a camera viewfinder, or with binoculars or a telescope even when only a thin crescent of the Sun or Baily's Beads remain. The 1 percent of the Sun's surface still visible is about 10,000 times brighter than the full moon. Staring at the Sun under such circumstances is like using a magnifying glass to focus sunlight onto tinder. The retina is delicate and irreplaceable. There is little or nothing a retinal surgeon will be able to do to help you. Never look at the Sun outside of the total phase of an eclipse unless you have adequate eye protection.
It's amazing how long the solar eclipse myth persists in spite of attempts to educate the public. There are still school principals in many countries that deny children the opportunity to view totality, one of the most wonderful sights in nature. During partial eclipse phases, solar filters that reduce luminosity by a factor of 10^5 will permit safe viewing. However, during totality, no filtering is required since the luminosity approximates that of a full moon. In my eclipse trips we often passed out filters to the interested public.