The piece of code bellow generates the error "Cannot retrieve heap variable of type 'Int32' as type 'DataToken'"
DataDictionary _dict;
// more code here that initializes the dictionary
void SomeFunction(EEnum enumVal)
{
DataToken key = (int) enumVal;
if (!_dict.ContainsKey(key)) //crash here
{
}
}
To fix it, I need to use Convert.ToInt32() instead of using a regular (int) cast, like this :
DataToken key = Convert.ToInt32(enumVal);
if (!_dict.ContainsKey(key))
The piece of code bellow generates the error "Cannot retrieve heap variable of type 'Int32' as type 'DataToken'"
To fix it, I need to use
Convert.ToInt32()
instead of using a regular (int) cast, like this :