Question: How do I get the following to show up (on stackoverflow) with color syntax highlighting?

class Foo
{
internal Foo()
{
for (int i = 0; i < 42; ++i);
}
}

Answer: 
See <https://stackoverflow.com/editing-help>.

Basically, for code, indent four spaces -- you can do this by pasting code then highlighting and hitting `Ctrl` + `K` or the ``{}`` button above the editing box.

As far as syntax highlighting, see [Changes to syntax highlighting](https://meta.stackexchange.com/questions/72082/changes-to-syntax-highlighting) and [Interface options for specifying language prettify](https://meta.stackexchange.com/questions/63800/interface-options-for-specifying-language-prettify/81970#81970).

The correct language will often be inferred by the tags on the question, but you can manually specify it with an HTML comment:

```
<!-- language: c# -->

    public static bool IsAwesome { get { return true; } }

```

or

```
<!-- language: lang-js -->

    setTimeout(function () { alert("JavaScript"); }, 1000);

```

before the code block.
If you want to insert code inline like this `int i = 0;` use backticks: ``int i = 0;``. If you want an entire block of code you can highlight it and then click the code button which looks like `{}`. You can also hit `Ctrl+K` while it's highlight, or just manually indent it all 4 spaces:

```
class Foo { internal Foo() { for (int i = 0; i < 42; ++i); } }

```