Female here. I've had it happen to me on a couple occassions, even when I was in 8th grade and used to dress a little boyishly and keepy my hair pretty short, I got asked on two seperate out-of-costume occassions, "Are you a boy or a girl?" and I guess I wasn't exactly pleased, but not exactly mad, so I would smile sarcastically and ask, "What do you think?"
In costume...well, I'm a crossplayer that doesn't wear a binder, however, with some of my costumes being rather bulky or particularly loose, the question does come up fairly frequently, and it's everything from genuine curiosity to outright rudeness, and as a cosplayer (or specifically, a crossplayer), I think that, unless you're a guy wearing a costume that doesn't require a shirt or a female wearing a costume that's practically a bra and a skirt, then it's really likely that the question is going to come up. Typically, I'm pretty pleased to hear it, because to me it simply means that I did a good job on my makeup.
*Kefka Palazzo - Final Fantasy VI (Being repaired.)
*Kankuro - Naruto
*Ryoga Hibiki - Ranma 1/2
*Soul Eater Evans - Soul Eater
*Antonio Salieri - Mozart L'Opera Rock
*Rapunzel - Tangled
*Miss Martian - Young Justice - 70%
*Monkey D. Luffy - One Piece - 60%
*Kotetsu T. Kaburagi - Tiger & Bunny - 40%
*Ryuk - Death Note - 30%
*Toph Bei Fong - Avatar: The Last Airbender - 5%