Regarding legality: If you wrote that answer yourself, you are the copyright holder, you just decided to license the text for Stack Exchange under the CC-BY-SA license. But you are still free to license that text to others (e.g. Wikipedia) under different (or same) license too.
If someone else wrote the answer, there are two questions:
- Under what conditions can you copy the text from SE?
- Under what conditions can you include the text into a Wikipedia article?
As mentioned above, all questions and answers on SE sites are licensed under CC-BY-SA, which means you can copy them as long you attribute the original author (e.g. by including a link) and don't restrict the use of the copy. Because Wikipedia also uses CC-BY-SA, this second condition is fulfilled.
So, the answer to question 1. is that if you include a link to the original, you are fine. (To include that link, you can use the CCBYSASource template).
Regarding question 2., read WP:COPYOTHERS. It explains that copying text from works “available under terms that are compatible with the CC-BY-SA license” is okay.
But another requirement for Wikipedia articles is one of verifiability, based on reliable sources. And a SE site is not a reliable source. What this means is that you can't use some answer as a source for a Wikipedia article, but you can include the text from an answer to an article, citing other sources (possibly ones that were already cited in the original answer).