If I have a generic class:
class Collection < G > {
public G[] stuff
}
and I have two other classes, one of which can convert to the other (though more complex than this!)
class Foo {
public Foo( int i ) { myInt = i; }
public int myInt;
}
class Bar {
public Bar( float f ) { myFloat = f; }
public float myFloat;
public static implicit operator Foo( Bar bar ) {
return new Foo( Math.Ceil(bar.myFloat) );
}
}
And I have collections of both:
Collection < G > fooCollection = new Collection < Foo > ();
Collection < G > barCollection = new Collection < Bar > ();
I want to be able to do something like this:
Collection < G > fooCollection2 = barCollection.Convert( typeof(Foo) );
How would I go about that?