Properties in C# and prop_Foo
Bill Baxter
wbaxter at gmail.com
Sat Aug 8 21:23:06 PDT 2009
On Sun, Aug 9, 2009 at 10:43 AM, Bill Baxter<wbaxter at gmail.com> wrote:
> Interesting thing I found out about C# properties.
> The syntax
>
> int Thing {
> get { return _thing; }
> set { _thing = value; }
> }
>
> is rewritten by the C# compiler into
>
> int prop_Thing() { return _thing; }
> void prop_Thing(int value) { _thing = value; }
>
> Just thought it was interesting given all our discussions,
> particularly that the syntax C# translates into is exactly what Andrei
> was proposing we use for D's syntax. And I think I even said that was
> fine, but let's have a different syntax for declaring that the D
> compiler translates into those prop_Thing methods. Well, it turns out
> that's exactly what C# does.
Dang I remembered wrong from what I read yesterday. C# turns it into
int get_Thing() { return _thing; }
void set_Thing(int value) { _thing = value; }
I don't recall anyone proposing exactly that for D. There was
prop_Thing, and there was getThing. So what C# uses is a mix of
those.
--bb
More information about the Digitalmars-d
mailing list