Skip to content
Advertisement

How to convert enum value to int?

I have a function which return a type int. However, I only have a value of the TAX enumeration.

How can I cast the TAX enumeration value to an int?

JavaScript

Advertisement

Answer

You’d need to make the enum expose value somehow, e.g.

JavaScript

(I’ve changed the names to be a bit more conventional and readable, btw.)

This is assuming you want the value assigned in the constructor. If that’s not what you want, you’ll need to give us more information.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement