Here are some resources;
Mutton paya recipe – BakraEid special
Here is the recipe;
Here is another one (recipe is different);
The last one;
Convert List of DerivedClass to List of BaseClass
Here is a good discussion;
https://stackoverflow.com/questions/1817300/convert-listderivedclass-to-listbaseclass
Getting all types that implement an interface
Using reflection, this is how we get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations.
var type = typeof(IMyInterface);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p));
Basically, the least amount of iterations will always be:
loop assemblies
loop types
see if implemented.
References
https://stackoverflow.com/questions/26733/getting-all-types-that-implement-an-interface
When to use <> instead of ()
When we are suppose to use different parentheses in C#. When I run into a situation where i am trying to tell if i need to put <> or ().
The dumbed down version to explain is this;
() are for variables. <> are for types. If you have both, <> always comes first.
You would never has A(int). It would be A<int>. You’d also never have B<5>. It would always be B(5). And, rule two, you might have C<int>(5), but never C(5)<int>.
<> are used in generics.