this is my method: GetListItemsPainted<T>(List<T> list)
and i don’t know what type is that list of,
how can i create new list that would have the passed list type?
something like this:
List<list.GetType()> newList = new List<list.GetType()>();
how can i cast my list to the real type so i would have all his properties etc.?
thanks
You do not have to create a new List, you already have one.
If you require a specific type, then constrain your generic type parameters with a
whereconstraintIf you intend to react to a wide variety of arbitrary types, which is a bad design decision in my opinion, then you will need to use a conditional with
.Cast<T>()something like:
But again, I would consider using a constraint.