Tuesday 3 July 2007

Automatic Properties (Continued)

Following on from yesterdays post about Automatic Properties.

It has been asked, "How do i access the private field"? Unfortunately you can't (you would need to use the normal property declaration to do that).

The private field is automatically generated by the compiler (which you do not have access to). If you wish to look at the private field declaration use ILDASM.

TODO: ILDASM Screenshot

Since you do not have access to the autogenerated private field, you will always been modifying its data through its accessors rather than directly.

Although has a slight performance hit, this inturn will produce more maintainable code.

No comments: