I have a bit complicated issue to solve.
I have a list of objects though later the list will be filled with two different type of instances.
First type is MyFirstType<T1, T2>
and second type is MySecondType<T>
Now I need to run though the list of objects and ask which one of the two is each item. Then I need to do some custom logic on the item.
For example:
foreach(object obj in list)
{
if(obj is MyFirstType<T1, T2>)
{
// do something
}
else if(obj is MySecondType<...>)
{
}
}
The problem is T or T1 and T2 could be any types so how do I write such an if - Is Keyword statement that only comparies if MyFirstType but not the generics inside? if(obj is MyFirstType<T1, T2>)
does not work since it needs concrete types for T1 and T2.
Like mentioned just need comparison without T1 and T2. Any ideas how to solve this?