I have come across this scenario on several occasions where a user posts a comment that answers the question. When they receive positive feedback, they post it as an answer. Is this bad practice? In my own case, if I am not 100% sure I will comment first and see if that worked for the OP. Sometimes there are more than one problem and that is why I don't post an answer immediately. Here is an example question that illustrates the issue. Should the first commenter get the credit, or the first answerer?
What is meta?
- Any Stack Exchange user can ask a question
- The community provides support, votes on ideas, and reports bugs
- Your voice helps shape the way Stack Exchange operates
Yes, that's bad practice, for two reasons. It's also a bad idea, for the last reason.
1. It's not what comments are for.
Take note of what the comment text box says before you start typing in it:
Comments are for requesting clarification on a question, and for others to respond to such requests. They are not for answering the question. Comments are transient. They can be deleted liberally by moderators. Nothing should be posted in them that needs to last forever.
On Stack Overflow, this is no less the case, but comments rarely get deleted because there's such an overwhelming number of them the moderators can't keep up.
On other SE sites where the moderators can keep up, you may see these comment rules actually getting enforced - for instance, they're very firmly enforced in RPG.SE. If you try to answer in a comment there and a mod notices it (they probably will), your answer-as-a-comment will be deleted.
2. It's an answer. Post is as such.
If you have the answer, post your answer as an answer. That way, it can get upvoted, downvoted or accepted, and won't be deleted or cleared away like comments can or will be. Comments can be deleted liberally - they are not meant to last forever.
If the question gets answered, there should be an answer to be marked as accepted, or at least upvoted. Not a comment.
Other people can and will post that answer as an actual answer
Numerous times, I've seen someone answer the question in the comments - then, since there's no answer on the question yet, someone else will come along and provide roughly the same answer as an answer. They get upvoted, and accepted.
This isn't a matter of plagiarism: in all the case I've witnessed myself, the answerer has put actual thought into expanding on the idea and making the answer a good answer - they might have even seen the question at the same time as you, but whilst you were busy leaving comments, they were busy writing up their answer.
In your example question: the first to answer should get the credit. Whilst you were busy writing a comment, the first person to actually answer the question was busy writing up your question. If you're concerned your solution might have issues - that's why answers can be voted on and edited. I hope you've learned your lesson.