[Mono-list] cannot assign to <this> problem
yoros@wanadoo.es
yoros@wanadoo.es
Mon, 30 Dec 2002 18:14:42 +0100
--WIyZ46R2i8wDzkSu
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Sun, Dec 29, 2002 at 11:23:34PM +0100, Artur Karazniewicz wrote:
> Hello,
>=20
> 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#.
>=20
> Example:
> I'm going to implement Visitor which changes
> some things in visited object. In C++ right
> way to do so is:
>=20
> // C++
> class Visitor {
>=20
> void Visit( Foo& aFoo ) {
> aFoo.SetSomething( "something" );
> }
>=20
> }
>=20
> class Foo {
>=20
> void Accept( Visitor& aVisitor ) {
> aVisitor.Accept( *this );
> }
>=20
> }
> //
>=20
> // it works fine but in C# code like this:
>=20
>=20
> // C#
> class Visitor {
>=20
> void Visit( ref Foo aFoo ) {
> aFoo.SetSomething( "something" );
> }
>=20
> }
>=20
> class Foo {
>=20
> void Accept( Visitor aVisitor ) {
> aVisitor.Accept( ref this );
> }
>=20
> }
>=20
> fails during compilation with message:
>=20
> error CS1604: Cannot assign to `this'.
>=20
> 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?
--=20
Pedro Martinez Juli=E1
\ yoros@terra.es
)| yoros@wanadoo.es
/ http://yoros.cjb.net
Socio HispaLinux #311
Usuario Linux #275438 - http://counter.li.org
GnuPG public information: pub 1024D/74F1D3AC
Key fingerprint =3D 8431 7B47 D2B4 5A46 5F8E 534F 588B E285 74F1 D3AC
--WIyZ46R2i8wDzkSu
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE+EH8BWIvihXTx06wRAiDPAJ9NaVcakMdfl/X4LUaNtdS7Ax0aVgCgvBKD
aBsmr/LmEt65Rqb40uZh8YA=
=34XF
-----END PGP SIGNATURE-----
--WIyZ46R2i8wDzkSu--