Hi all
I was a Java programmer, I am used to doing something as followed:
IO Example: (It's not the best example I can come up with, but it is the simplest one)
Code:public interface IO<T>{ T parse(stream s); String print(T o); }Code:public class IOA extends IO<A>{ A parse(stream s){ A instanceA; // parse A return instanceA; } String print(A a){ return a.toString(); } }so far, everything can translate to C#Code:public class IOB extends IO<B>{ B parse(stream s){ A instanceA; //parse B return instanceB; } String print(B b){ return b.toString(); } }
BUT
I cannot find a way to translate the following to C#
Is it possible to translate this to C#?Code:public class Peeker{ public Parser<?> peekAndFindSuitableParser(stream s){ // peeking.... then determine if (/* need to return parserA */...){ return new ParserA(); } else if (/* need to return parserB */...){ return new ParserB(); } } }
If not, should I just remove all the generics in these code?




Reply With Quote