RE: [Ikvm-developers] Ghosts and generics
Brought to you by:
jfrijters
From: Jonathan P. <jp...@ny...> - 2003-10-16 02:13:38
|
Jeroen, I realized after I sent my last message that I had the wrong charAt definition but the code still illustrates the suggested approach. Here's the example that I meant to send: using System; public class CharSequenceHelper { public static CharSequenceHelper.CharSequence_charAt<string> kStringCharSequenceHandler = new CharSequenceHelper.CharSequence_charAt<string>(CharSequenceHelper .string_charAt); private static char string_charAt (string theString, int i) { return (theString [i]); } public delegate char CharSequence_charAt<T>(T v1, int i); public static char charAt<T>(T theCharSequence, CharSequence_charAt<T> theDelegate, int i) { return (theDelegate (theCharSequence, i)); } } public class Test { static void Main(string[] args) { string theTestString = "abc"; int theCharIndex = 0; char theFirstChar = CharSequenceHelper.charAt<string>(theTestString, CharSequenceHelper.kStringCharSequenceHandler, theCharIndex); Console.Out.WriteLine (theFirstChar); } } Jonathan |