C# 3.0 Automatic Properties

May 16, 2007

Yesterday I read two excellent posts about C# 3.0 automatic properties feature: ScottGu’s «New C# “Orcas” Language Features: Automatic Properties, Object Initializers, and Collection Initializers» and Bart De Smet’s «C# 3.0 Automatic Properties explained».

It was a pleasure to see that my old «A programming language pattern idea» hit straight to the point.

By the way, this “Orcas” feature is still missing the “container” concept, enabling an access to the auto-generated field from the constructor. Another missing point is a read-only automatic properties.

7 Responses to “C# 3.0 Automatic Properties”

  1. Hear, hear. I second the “missing read-only automatic properties”. Especially with anonymous classes created with LINQ via projection, the option to create those properties as read-only would be so useful.

    Maybe something like ‘new readonly { foo = “bar” };’

    Creating a writable anonymous class via projection at best leaves the impression that setting those values means something. In reality it is very likely just a way to give you data to look at. It certainly doesn’t propagate the changes back to the originating object.

  2. I thought about making an anonymous classes derived from LINQ queries to be immutable.

    But I see that there is nothing to complain about this: Sree just blogged that they decided to infer all anonymous classes as immutable.

  3. I did a first pass at implementing auto-properties in Mono: http://lists.ximian.com/pipermail/mono-devel-list/2007-May/023460.html

    I’ll be redoing this patch soon(ish). Should be done by the end of the week.

  4. Hi Scott!
    Good to hear about it, especially since I somehow missed your post on this.

  5. Nathan Says:

    Wow, awesome bloog layout! Howw long have youu beenn blogging for?

    youu makoe bloging looik easy. Thee overall look
    oof your website iis magnificent, lett alne thhe content!

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

%d bloggers like this: