Continuing Education

The longer I spend developing software, the more I realize there are vast areas of programming where I am helplessly clueless. Even within C# development, the domain where I am supposed to have most of my knowledge, it's not hard to stumble upon something I don't understand as well as I thought.

For example, let's take indexed properties. Most people are familiar with some variation of the following indexed property example:

public class MyClass
{
    char[] content;

    internal MyClass(char[] values)
    {
      content = values;
    }

    // This is an indexed property
    public char this[int index] 
    {
        get { return content[index]; }
        set { content[index] = value; 
        }
    }
}

One thing I never realized is that indexed properties can have multiple parameters:

public class MyClass
{
    char[][] content;

    internal MyClass(char[][] values)
    {
        content = values;
    }

    // This is an indexed property with multiple parameters
    public char this[int index1, int index2]
    {
        get { return content[index1][index2]; }
        set { content[index1][index2] = value; }
    }
}

Although Microsoft recommends against multiple parameters in their indexed property design recommendations, it's still a very basic aspect of the language that I was fully unaware of until recently.

In the case that you don't commonly find yourself wearing the hat of novice developer, feel free to browse the current set of unanswered C# questions over at Stack Overflow and share the wealth of your knowledge.

blog comments powered by Disqus