Enumeration Equals Method Causing : NullReferenceException: Object reference not set to an instance of an object

I am trying to compare 2 enums with the equals method, as the ‘’==‘’ would not work for me and I read online it was the wrong way to do it. So I’ve tried a few things.
First off the main snippet of the code, the error being thrown on the first line, where I try the equals method.

case BaseAbility.AbilityTypes.FLAME:
			if (enemy.PlayerClass.CharacterType.Equals(BaseCharacterClass.CharacterTypes.LEAF)) {
				Debug.Log("FLAME V LEAF SPECIAL MODIFIER");
				modifierValue = (int)(GameInformation.Special * playerSpecialModifier);
			} else if (enemy.PlayerClass.CharacterType.Equals(BaseCharacterClass.CharacterTypes.LEAF)) {
				Debug.Log("FLAME V RIVER SPECIAL MODIFIER");
				modifierValue = (-(int)(GameInformation.Special * playerSpecialModifier));
			} else {
				Debug.Log("MODIFER WAS NOT CALCULATED BECAUSE THERE WAS NO TYPE ADVANTAGE");
				modifierValue = 0;
			}
			break;

So I created a separate class just for enumerations, to compare from that. In the same way though. I can post any other info if needed. Really would appreciate help with this thank you so much in advance.

Not sure where you read that comparing enums with == was wrong, because it isn’t…

if (characterType == CharacterTypes.Leaf)...

is perfectly acceptable.

If you’re getting a null reference exception then it’s something else. Enums aren’t references so can’t give you a null reference exception. So either enemy is null, or enemy.PlayerClass, etc. Debug.Log is your friend here. Add in debug statements like if (enemy == null) Debug.Log("Enemy is null"). Add those for any reference you’re, um, referencing.