Archive for May, 2011

Posting Source Code

Posted: May 12, 2011 in Random Thoughts

I’m playing with various options for blogging about programming, and a big part of that is posting source code easily, in a way that looks good.

Let’s see how WordPress fares:

        private List<string> EmptyListWithSize(int size)
        {
            List<string> list = new List<string>();

            for (int i=0; i < size; i++ )
                list.Add("");

            return list;
        }

        private List<string> FilledListWithSize(int size, string value)
        {
            List<string> list = new List<string>();

            for (int i=0; i < size; i++ )
                list.Add(value);

            return list;
        }

OK, I’m pretty pleased with that. This uses Alex Gorbatchev’s excellent SyntaxHighlighter. WordPress has build in support for it.

For good measure, here’s some VB.Net code:

Public Class Temperature
    Public Value As Double
    Public Scale As TemperatureScale
    Public Sub New(ByVal newValue As Double, ByVal newScale As TemperatureScale)
        Value = newValue
        Scale = newScale
    End Sub
End Class