On Sun, Dec 29, 2002 at 11:23:34PM +0100, Artur Karazniewicz wrote:
> 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#???

I don't know what are you trying to do. Can you explain it?

-- 
Pedro Martinez Juli�
\  [EMAIL PROTECTED]
)|    [EMAIL PROTECTED]
/        http://yoros.cjb.net
Socio HispaLinux #311
Usuario Linux #275438 - http://counter.li.org
GnuPG public information:  pub  1024D/74F1D3AC
Key fingerprint = 8431 7B47 D2B4 5A46 5F8E  534F 588B E285 74F1 D3AC

Attachment: msg05189/pgp00000.pgp
Description: PGP signature

Reply via email to