It's not wrong, exactly, but it might upset your friend if she gets the wrong idea. Before hanging out with her ex-boyfriend, you might want to take the following things into consideration:
- How long have they been broken up for? If the relationship ended recently, your friend might still be getting over it, and would be hurt by the thought of her ex-boyfriend spending time with someone else.
- How close are you to your friend? If she's just an acquaintance, there's nothing wrong with it, but if she's your best friend, you might want to think about how you'd feel if it was the other way round, and she was hanging out with your ex.
- Does your friend's ex want to be more than friends? If you know that your friend's ex-boyfriend has a crush on you, then you're being unfair to both of them by hanging out with him. You risk hurting your friend's feelings and giving this boy false hope.
Only you will be able to decide whether it's best to tell your friend that you're hanging out with her ex. Just keep in mind that she might fly off the handle if she finds out about it from someone else, so hiding it from her might not be the best of ideas! If you tell her and she's not happy, just explain that there's nothing going on.
Ultimately, it's your choice who you spend your time with, but if you value your friendship, you might be better off avoiding your friend's ex.