For reference, see http://daringfireball.net/projects/markdown/syntax, which is linked in the formatting question box.
Inline code
For simple cases, use double backticks: ``List`1`` produces List`1.
To put one or more backticks at the beginning or the end of your code, e.g., foo`, `foo, or just `, add a space on each side as well:
`` foo` `` produces foo` `` `foo `` produces `foo `` ` `` produces `
Without these spaces, parsing breaks:
``foo``` produces ``foo``` ```foo`` produces ```foo`` ````` produces `````
Space is needed on both sides, even if a backtick only appears on one side of the intended code. Otherwise, the space itself may be considered part of the code span:
``foo` `` produces foo` `` `foo`` produces `foo
If the inline code must contain a longer sequence of backticks, use a backtick sequence at the start and end that is longer than anything in the code itself:
```foo``bar``` produces foo``bar ````foo```bar```` produces foo```bar
And so on. You can also see this technique in action in the source code of this answer.
Code blocks
Code blocks can be created either using "code fences" (lines before and after with three or more backticks), or by indenting each line of the code by an additional four spaces (above and beyond the code's indentation, as well as any indentation needed to put it inside a bullet-point list etc.).
The extra-indentation approach makes it simple to include backticks in the code block, but can otherwise be unwieldy.
With code fences, there is usually no problem with putting backticks in the code:
` this works this also works: ``` ``` it even works with text here
However, this breaks if the code block must have three backticks on a line by themselves, even with leading and/or trailing spaces. In this case, we again fix the problem by using a longer sequence of backticks on the start and end lines. For example, source like
```` ``` ````
produces
```
\Example:`