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
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s