O'Reilly logo

C# 5 First Look by Joel Martinez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C# 2.0

The first major update of the C# language, Runtime, and .NET Framework was a big one. This release focused on making the language more concise and easier to write.

Syntax updates

The first update added a small capability to the property syntax. In 1.0, if you wanted a read only property, your only choice was to exclude the setter, as follows:

private int _value;

public int Value
{
    get { return _value; }
}

All internal logic had to interact with the _value member directly. In many cases this was fine, except for cases where you needed to have some sort of logic governing when and how you were allowed to change that value. Or similarly, if you needed to raise an event, you would have to create a private method as follows:

private void SetValue(int ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required