Problem:
When I cast an entity type to a generic, or cast a generic to an entity type, you are prompted not to convert.
As in the following code:
Personinfor is an entity class and T is a generic type
Public int Getpersonmsgw_<t> (refstring ImagePath) {
//Generic conversion to entity type Object temp = pInfo; = (personinfor) temp;
The entity type is converted to generic = pi ; = (T) temp; return 0; }
You see, obviously, I'll assign the generic or entity type first to the middle variable, object, and then use that intermediate variable for the cast.
The reason, the generic type is a variable, can not determine which type, gu can not directly convert, and the assignment to the intermediate variable indirectly determined its type, Gartner to convert.
Above is personal opinion, the wrong place also please correct me!!
Mutual transformation between generics and entity classes