Haroon,
Don't worry about passing through someone else's code. This isn't rocket-surgery! How on earth are you supposed to know all the other codes that airplanes, being picked up on the same radar screen as you are, would be squawking? And then if you did know them, to move your dials so as not to end up squawking the same code as any other airplane! It's ridiculous!
When ATC says to squawk a code, change to that code immediately and don't select an emergency code. The end.