So something like this:
Rectangle myRec = new Rectangle();Can become:
myRec.Width = 50;
myRec.Height = 50;
Rectangle myRec = New Rectangle() { Width=50, Height=50 };There are some restrictions though:
- Can only initialize properties or fields accessible by the object being initialized.
- This means that you cannot set attached properties in this manner [ie. Canvas.Top], as these properties can only be set with the SetValue function.
- The assignments in the initializer is treated the same as assignments to members of the field/property.
See here for a little more
And this msdn page
.
No comments:
Post a Comment