What I do in this case is create an interface that is not generic. Seems to work well. Of course more stuff to deal with, but still means you can have generics of different types saved in a variable.
Interface IJigger<T>
{
T DoSomething();
}
class jigger<T> : IJigger
{
public T DoSomething() {}
}
foreach(var i in mixedbag)
{
// This is what I can't figure out:
if(i is IJigger)
((IJigger)i).DoSomething();
}
Note: Using
(i as jigger<>)
really buys you nothing. Use
cast
instead. If
(i as IJigger)
is null you crash anyway.