If T in your example is some base class that inherits all the objects in the queue , you can simply pass this to the method instead of T :
public List<QueMessage> getMessagesFromObj1Queue<T>(QueueObjBase que) { ... }
Otherwise, if a common interface appears that will be implemented by all T , use this as a general constraint:
public List<QueMessage> getMessagesFromObj1Queue<T>(T que) where T : [yourInterface] { }
Without a general restriction on T , the compiler has no information to know which method or properties are available, and therefore can only process T as an object - which, of course, the RecieveAll() method does not have.
source share