WordPress includes a neat feature allowing you to paste code into your posts – and allows it to retain its formatting.
An example below – and more details can be found here http://en.support.wordpress.com/code/posting-source-code/
// Hello1.cs
public class Hello1
{
public static void Main()
{
System.Console.WriteLine("Hello, World!");
}
}