RE: [Ikvm-developers] Ghosts and generics
Brought to you by:
jfrijters
From: Jeroen F. <je...@su...> - 2003-10-17 14:25:11
|
Hi Jonathan, I still don't see it. If I statically know that the type is a string, why do I need all this complicated stuff? I can just call StringHelper.charAt().=20 Regards, Jeroen=20 > -----Original Message----- > From: Jonathan Pierce [mailto:jp...@ny...]=20 > Sent: Thursday, October 16, 2003 04:11 > To: 'Jonathan Pierce'; Jeroen Frijters > Cc: ikv...@li... > Subject: RE: [Ikvm-developers] Ghosts and generics >=20 > Jeroen, >=20 > I realized after I sent my last message that I had the wrong charAt > definition but the code still illustrates the suggested approach. >=20 > Here's the example that I meant to send: >=20 > using System; >=20 > public class CharSequenceHelper=20 > {=09 > =20 > public static CharSequenceHelper.CharSequence_charAt<string> > kStringCharSequenceHandler =3D=20 > new > CharSequenceHelper.CharSequence_charAt<string>(CharSequenceHelper > .string_charAt);=09 >=20 > private static char string_charAt (string theString, int i)=20 > {=20 > return (theString [i]);=20 > } =09 >=20 > public delegate char CharSequence_charAt<T>(T v1, int i); >=20 > public static char charAt<T>(T theCharSequence,=20 > CharSequence_charAt<T> > theDelegate, int i) { > return (theDelegate (theCharSequence, i)); > } > } >=20 > public class Test=20 >=20 > { =20 > static void Main(string[] args) >=20 > { > string theTestString =3D "abc"; > int theCharIndex =3D 0; > char theFirstChar =3D=20 > CharSequenceHelper.charAt<string>(theTestString, > CharSequenceHelper.kStringCharSequenceHandler, theCharIndex);=20 > Console.Out.WriteLine (theFirstChar);=09 > } >=20 > } >=20 > Jonathan >=20 >=20 >=20 >=20 |