Can anyone explain to me how an a member of this enum takes a value of 0
?
public enum EnumLogicalOperator
{
And = 1,
Or = 2
}
An enum type is a special data type that enables for a variable to be a set of predefined constants. The variable must be equal to one of the values that have been predefined for it.
An enumeration type declaration gives the name of the (optional) enumeration tag. And, it defines the set of named integer identifiers (called the enumeration set, enumerator constants, enumerators, or members). A variable of the enumeration type stores one of the values of the enumeration set defined by that type.
Enumeration or Enum in C is a special kind of data type defined by the user. It consists of constant integrals or integers that are given names by a user. The use of enum in C to name the integer values makes the entire program easy to learn, understand, and maintain by the same or even different programmer.
Enum types cannot be nullable.
Whenever you use default(EnumLogicalOperator)
or new EnumLogicalOperator()
you'll get a zero value. In other words, the default value of an enum type member is always 0. All enums will have the value 0 until you set them to something else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With