Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 158 Stack Exchange communities.

What is meta?
Here's how it works:
  1. Any Stack Exchange user can ask a question
  2. The community provides support, votes on ideas, and reports bugs
  3. Your voice helps shape the way Stack Exchange operates

Sometimes code is included in an answer in order to show what not to do. For example:

String foo = null;
String.IsNullOrEmpty( foo.Trim())

...Throws an exception as foo is Null.

The correct code is usually listed later in the answer. In the interest of preventing careless visitors from quickly copying and pasting the code the author didn't want them to use, it would be nice if there was a way to mark bad or dangerous code so the background was a light red color instead of grey (for example).

As an example of how this could be automatically displayed, when the first line of a code block is a comment with a particular message, the code block's background would be changed, or perhaps a little warning triangle icon would be added.

Trigger possibilities:

// Bad code
/* Dangerous code */
# Incorrect code

Just an idea.

share|improve this question
Related (and far more generic, and hence more useful in my opinion): Allow highlighting certain bits of a code fragment or quote. – Arjan Mar 11 '11 at 16:51

If people are just blindly pasting code without thought or care they kind of deserve what they get, don't you think? It might sound harsh but I definitely don't want that coder writing stuff that I'm going to use or maintain.

A way to highlight code manually might be useful though.

share|improve this answer
I still think the suggestion would be useful, just not for the same reason. If your first block of (bad) example code is clearly marked, it might stop people from downvoting without finishing reading your answer. – Bill the Lizard Mar 12 '11 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .