Anders Hejlsberg on C# Futures

I just finished watching MSDN TV. This time around it was Anders Hejlsberg, the man I personally blame for the features that I love and hate in C#. One of the things that really got me interested (there were several hypotheticals for C# 3.0 and beyond) was what I could call in-line configuration of objects at instansiation. My example would be a private field on a class.

private MyClass m_MyClassInstance = new MyClass() { X = 1, Y = 2 }

Where X and Y would be properties or fields on the class. I easily run out of fingers and toes when it comes to identifying times where I could have used this. You see the way that you would have to do this previously is drop some initialization code into the constructor – not a bad solution, but the above mechanism co-locates the relevant initialisation code with the field itself.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s