How NPN transistors and PNP transistors function as a switch?

both NPN and PNP transistors consist of three regions- collector, base and emitter.

the can use a transistor as a switch using the property that whenever there is a current flowing from the base to the emitter(or emitter to base in case of PNP), and a potential drop across collector-emitter region(across emitter-collector region in case of PNP), then the collector-base-emitter give a very low resistance(in ideal case, shorted) and if there is no current flowing from base to emitter region(emitter to base in case of PNP), then collector-base-emitter will give a very high resistance(in ideal case, open).

in order to use a transistor as a switch, we connect the end points of the switch to collector and emitter...and whenever we give a pulse of current of required magnitude and polarity, the transistor will allow current through it and else will remain off.