The simplest way is to just paste your code in: when you do that a pop-up appears giving you options for how to paste it. Generally, these contain:
Paste as-is
Encode HTML
Code Block
Quoted Text
Best Guess
And a small preview of what it will insert as you hover the mouse over the options.
If I paste in some C#
List<string> myList = new List<string>();
if (a == b)
c();
"Encode HTML" and "Code Block" are probably the ones to start with:
Encode HTML:
List<string> myList = new List<string>();
if (a == b)
c();
Which displays as:
List<string> myList = new List<string>();
if (a == b)
c();
Code Block:
List<string> myList = new List<string>();
if (a == b)
c();
You can also paste code and use the
code
widget above the text box to add the formatting you want.