When I was that age I threw a temper tantrum in a store with my dad because he wouldn't buy me the kind of character-printed leggings the other girls in my preschool wore (it was the 80s, we all got dressed funny, what can I say) and overall I turned out fine. Oh wait...

Ok, really though...At that age, and given the circumstances, I'm not sure I would "say" anything outright in terms of asking what gender they feel they are. Playing is just playing, more likely than anything. If things move beyond playing I would keep it to offering assuring and affirming choices for your child to express themselves, within reason of course. Like if your son wants to wear a dress, maybe go shopping and let him (for lack of an explicitly declared gender) pick something out that he likes. Or if he doesn't want to get his hair cut short, give him the choice of growing it out longer and see where that goes. The best thing you can probably do is give your child a supporting and affirming environment to explore how they want to express themselves so they can be confident in who they are and how they're presenting themselves to the world. If things go further than exploring, check out the resources TYFA has available for parents of trans & gender-variant children.
And I said above "given the circumstances" only meaning that I know I would probably be overly sensitive and quick to pick up on gender-variant behavior in my child because, well, I've lived it myself and I can't help but look for it in others. If my son or daughter eventually came to me and told me they were a girl or a boy, or neither, I would let them guide what they wanted to do with that (again, within reason) and prepare myself to support and back them up fully when people try to make that difficult.