For code like, duplicate, only parameter, return value type is different, of course, is the generic method, generic class.
The use of generic methods, generic classes, can be a good way to improve code reuse.
However, it is not always a good time to adopt a generic type.
As mentioned above, arguments and return values are different, and you can use generics. However, these generics are used only on parameters, return values, and may not be appropriate if they are used within the body of the function to use the properties and methods inside these generics. At this point, there is bound to be a cast statement. The question is, what is converted into? If these generics are programmed for the interface, they can, of course, be turned into interfaces; otherwise, generics are not suitable for use in these methods. This is my previous time encountered problems and experience.
Not an example.
=========================================
With regard to the limitations of generic methods, I think of one way of coping: Using reflection to access generic objects.
See
http://blog.csdn.net/leftfist/article/details/49784855