Properties: a.b.c = 3
Ary Borenszweig
ary at esperanto.org.ar
Thu Jul 30 12:01:29 PDT 2009
Steven Schveighoffer wrote:
> On Thu, 30 Jul 2009 14:40:21 -0400, Nick Sabalausky <a at a.a> wrote:
>
>> "Chad J" <chadjoan at __spam.is.bad__gmail.com> wrote in message
>> news:h4oku0$uel$1 at digitalmars.com...
>>> Daniel Keep wrote:
>>>>
>>>> Maybe the compiler could rewrite the above as:
>>>>
>>>> auto t = a.b;
>>>> t.c = 3;
>>>> a.b = t;
>>>>
>>>
>>> I'd always suspected C# properties did something like this, though it's
>>> been so long since I've used C# now that I'm wondering if it's bad
>>> memory.
>>>
>>
>> Same here, so I just did a little test in Visual C# 2008 Express.
>> Turns out
>> that rewriting *is* exactly what C# does.
>>
>> Code:
>> --------------------------------------
>> using System;
>>
>> namespace ConsoleApplication1
>> {
>> class Program
>> {
>> class Rect
>> {
>
>
> Change Rect to a struct, try again. Classes are reference types (note,
> I don't have a C# compiler handy, so I'm not sure what the result is).
It gives a compiler error, I already posted that somewhere else:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=94292
More information about the Digitalmars-d
mailing list