Cannot convert type ‘System.Enum’ to int

System.Enum cannot be directly cast to Integer, but it does explicitly implement IConvertible, meaning you can use the following:

public void AddLink(Enum enumVal)
{
    string identifier = m_EnumInterpreter(Convert.ToInt32(enumVal));
    AddLink(identifier);
}

Keep in mind that if your Enum is actually using something other than an Integer (such as a float), you’ll lose the non-integer data on conversion. Or obviously replace the Convert call with whatever you are converting from (if it’s known)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)