Getting to know her is the first step. Some people say that you should ask for a girl’s number before they’ve even spoken with her for more than two minutes. However, this usually only works well if you know that you won’t see her again for a long while. Spend some time with her and befriend her, but don’t hang around her all the time and abandon your friends (or keep her from hers). If she feels like she’s giving her number to a (non-clingy) friend and not a potential boyfriend/girlfriend, she may feel more comfortable about giving you her number. Be careful about setting up too much of a platonic relationship. Try to set her at ease when you talk to her. If she thinks you’re creepy or dangerous, she won’t want to give you her number.
One way to keep things going is to ask if you can walk with her; another is to sit next to her in class. Whatever tactic you use, make sure she’s enjoying the conversation as much as you are. If she isn’t responsive, take a hint and leave her alone for a while. See if she comes to you. If she doesn’t engage, then don’t force it. Don’t worry if she doesn’t talk to you; it happens to everyone.
Try to be clear about it. Don’t stutter, don’t hesitate, and don’t beat around the bush. Just say, “Hey, can I have your number?” Don’t have anyone else do it for you. Don’t ask her friend for her number. If you’re going to impress her and do it right, you need to work up the courage to ask her yourself.
If you’ve made plans to study with her, ask for her number to make it easier. Say, “Hey, can I get your number so that we can make plans to study?” If you’re going somewhere with a big group, ask for her number to help get together with the group. Say, “Tonight seems like it’s going to be pretty hectic, and I might be a bit late. Can I get your number so that I can find you guys if I have any trouble?”
A lot of the time girls just want to figure out what kind of person you are. If you can, strike up a polite and friendly conversation about something that she’s into (or a teacher, a club, or a particular subject). Consider simply invite her and her friends out with you and your friends. You could go bowling and get an ice cream after, or you could go to a movie, or hang out in the park. This way, she can see what kind of person you are, and it may inspire her to give you her number.
Consider finding a reason to cut the conversation short. If you’ve gotten a good talk going, and you find a natural lull, you can say, “It’s been great talking to you, but I need to go to practice now. I’ll talk to you later :)” If things were going well, then this might leave her wanting more. If the first few texts naturally bloom into a huge, days-long conversation over multiple messaging media – let it happen. This almost certainly means that she likes you.
If you ask her a question and she sends you a long answer—at least a few sentences—then you should definitely keep asking questions. If she asks you questions back, that’s even better. If you ask her a (deeper than yes-or-no) question and she responds with “yeah” or “idk” or anything along those lines – she is probably either shy or uninterested.