I think that pushing the boundaries of your creativity by writing in the opposite gender is a worthwhile exercise. Rose Tremain created a very believable male character, Merivel, in her novel Restoration.
I need to understand what makes a characters tick before writing from their perspective. As a white, working class, retired engineer, I can write from my own experience, imagination and insight from life experiences.
Some of this can transfer, genderless, to character of the opposite sex. So, for example, I wrote a short story about a white witch. Her gender was irrelevant.