Get rid of the 'ref' keyword in both places - it isn't needed(or allowed, as you can see). You will get the semantics you want without it.
-- Arild Fines > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On > Behalf Of Artur Karazniewicz > Sent: 29. desember 2002 23:24 > To: [EMAIL PROTECTED] > Subject: [Mono-list] cannot assign to <this> problem > > > Hello, > > I'm new to C# but I've coded a lot in C++ and > I'm trying implement Visitor pattern > in C# - and i'm not sure how to get double > dispatch mechanism to work with C#. > > Example: > I'm going to implement Visitor which changes > some things in visited object. In C++ right > way to do so is: > > // C++ > class Visitor { > > void Visit( Foo& aFoo ) { > aFoo.SetSomething( "something" ); > } > > } > > class Foo { > > void Accept( Visitor& aVisitor ) { > aVisitor.Accept( *this ); > } > > } > // > > // it works fine but in C# code like this: > > > // C# > class Visitor { > > void Visit( ref Foo aFoo ) { > aFoo.SetSomething( "something" ); > } > > } > > class Foo { > > void Accept( Visitor aVisitor ) { > aVisitor.Accept( ref this ); > } > > } > > fails during compilation with message: > > error CS1604: Cannot assign to `this'. > > I dont know - how can I implement such kind > of double dispatch in C#??? > > regards > Artur. > > > _______________________________________________ > Mono-list maillist - [EMAIL PROTECTED] > http://lists.ximian.com/mailman/listinfo/mono-list _______________________________________________ Mono-list maillist - [EMAIL PROTECTED] http://lists.ximian.com/mailman/listinfo/mono-list
