Re: C# 3.0 Automatic Properties

Fabian Schmied <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.clr
Message-ID <[email protected]>
> Nope:
>
> MyType x = new MyType();
> SomeMethod (ref x.SomeField); // Fine
> SomeMethod (ref x.SomeProperty); // Not fine
>
> Also, if you're crazy enough to have mutable structs:
>
> StructHolder holder = new StructHolder();
> holder.SomeField.Age = 10; // Valid
> holder.SomeProperty.Age = 10; // Invalid
>
> Those are just off the top of my head.

Okay, you are right, I was too fast; some incompatibilities do exist
at the source code level. Still, I'm convinced that typical readonly
field applications ("utility struct" scenarios) don't profit from the
additional encapsulation provided by automatic properties. The
constructs you provided also don't work with readonly fields, I
believe :)

Fabian

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.