It would have been better if you had more control on the properties in C#:
class Foobar
{
int myFoo;
property int MyFoo
{
public get
{
return myFoo;
}
internal set
{
myFoo = value;
}
}
}
I have not yet looked at properties in C# 2.0, but I'm sure that this has
not yet been implemented.
Since those properties are translated into methods (get_MyFoo()
set_MyFoo() [weird, the D code below works fine without the ugliness of
get_ and set_ prefixes]), similar to the D code below, the only thing that
needs to be changed is the C# compiler to support this type of control.
In the D programming language, you do have something like this:
class Foobar
{
private int myFoo;
public int MyFoo()
{
return myFoo;
}// read property
protected void MyFoo(int value)
{
myFoo = value;
} // write property
}
To use it:
void main()
{
Foobar f;
put(f.MyFoo); // same as f.MyFoo();
f.MyFoo = 3; // same as f.MyFoo(3); error inaccessible
f.MyFoo + 3; // same as f.MyFoo(f.MyFoo() + 3); error inaccessible
}