I don't even think I have the question correct as I am just starting with generics and my knowledge isn't very great.
Say I have the following method:
public class Wrapper
{
public List<TInfoType> GetInfo<TInfoType>(Array data, EdmCmd edmCmd)
{
switch (edmCmd.meCmdType)
{
case EdmCmdType.EdmCmd_PostAdd:
List<EdmCmdPostAddInfo> info = new List<EdmCmdPostAddInfo>();
foreach (EdmCmdData item in data)
{
info.Add(new EdmCmdPostAddInfo(item.mlObjectID1, item.mlObjectID2, item.mbsStrData1, item.mlLongData1));
}
return info;
break;
default:
break;
}
}
}
And I would like to call the method like:
List<EdmCmdPostAddInfo> info = wrapper.GetInfo<EdmCmdPostAddInfo>(data, edmCmd)
What is the correct way to do this? I am getting the error:
Cannot implicitly convert type 'System.Collections.Generic.List<EPDM.Utils.EdmCmdPostAddInfo>' to 'System.Collections.Generic.List<TInfoType>'
I am doing this because the EdmCmd struct that is passed to the method has various members that are generically named. It's difficult to remember what the members represent for each CmdType, so I am wrapping them in a more meaningful struct.