I concur with Erik's answer that this is plagiarism.
It may, or may not, also be a copyright violation, depending on what the license of the original content is. (If it is from within Stack Exchange, then it definitely is, since CC BY-SA 3.0 requires attribution, and thus plagiarism is always automatically a copyright violation.)
There is actually another dimension in addition to the legal (copyright violation) and moral (giving credit to the author) ones. At least in academic circles, the reason why plagiarism is so heavily abhorred is that in the scientific method traceability of ideas is important. In order to investigate the merits of an idea, you need to know its context and its history, its "genealogy" if you will. Plagiarism obscures this.
This is also important on a Q&A site like the Stack Exchange network. Imagine, you discover a flaw in that answer, and want to correct it. With proper attribution, you can trace the code all the way back to the original source and inform everybody along that path of that flaw. Maybe the framework used changed its API, maybe the language deprecated a keyword, maybe a new framework that better solves the problem came out, maybe there is a security hole in the code.