I inherited from the generic version of list to add some properties to anhother generic class in asp.net core then I have a method that receive an object parameter. In some point of the workflow of the framework, it convert my class to an object and pass it to this method. So, I need to cast or parse the object to a specific class of my inherited class.
public class ClassList<T> : List<T>
{
public int SomeProperty {get; set;}
....
}
public void SomeMethod(object value){
}
I need to cast the object in the SomeMethod method to an specific type of the generic class that I've created.
Something like this:
ClassList<OtherClass> otherList = (ClassList<OtherClass>) object;
The problem is how to know the type of the generic type and how to convert the object to this type at runtime?