Mogę zadzwonić Get<int>(Stat);lubGet<string>(Name);
Ale podczas kompilacji otrzymuję:
Nie można niejawnie przekonwertować typu „int” na „T”
i to samo dla string.
public T Get<T>(Stats type) where T : IConvertible
{
if (typeof(T) == typeof(int))
{
int t = Convert.ToInt16(PlayerStats[type]);
return t;
}
if (typeof(T) == typeof(string))
{
string t = PlayerStats[type].ToString();
return t;
}
}