[Mono-list] C# General Question...
Dan Guidara
dan@guidara.com
11 Jan 2003 20:24:22 +0000
On Fri, 2003-01-10 at 19:09, Eric J. Peters wrote:
> Hi-
>
> While this isn't a mono-specific question, I think this list, being
> very technical and C# based, is the best place I know of to ask.
>
> Imagine a class as shown here:
>
>
> class A {
> private int m_data = 1;
> public int Data {
> get { return m_data; }
> }
> protected int Data {
> set { m_data = value; }
> }
> }
>
>
> Obviously, this is a compile-time error. My specific question is if
> there is a language mechanism to allow for different access levels between the
> two different accessors. If not, then I would be interested in hearing why
> not -- it seems like a significant oversight to me.
>
> Thanks,
> -Eric.
>
> _______________________________________________
> Mono-list maillist - Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
Eric,
I am not sure why you would want to do that. Its my understanding that
Properties are public in their nature to allow an interface for setting
internal variables in a controlled manner from extranal classes, etc. I
quess you could create functions with the desired protection levels to
read and write the values. I am not sure where the oversight comes into
it at all.
Dan