After you engage them in conversation, just tell them you'd like to talk to them again - in just those terms. "I want to talk to you again. What's your number?" or "How do I reach you again?"
I've always felt that pulling out a cell phone and punching in the digits cheapens the mood. Fortunately, my work requires me to keep a pen and paper handy.
Then part ways as if you were on your way.
If it's someone you have repeated contact with, be patient with it. Wait for the right moment to get close.