Struct Enum<E>
Provides strongly typed way to reflect enum type.
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public struct Enum<E> : IEquatable<E>, IComparable<E>, IFormattable, IEquatable<Enum<E>>, ISerializable where E : struct, Enum
Type Parameters
Name | Description |
---|---|
E | Enum type to reflect. |
Fields
| Improve this Doc View SourceMaxValue
Maximum enum value.
Declaration
public static readonly Enum<E> MaxValue
Field Value
Type | Description |
---|---|
Enum<E> |
MinValue
Minimum enum value.
Declaration
public static readonly Enum<E> MinValue
Field Value
Type | Description |
---|---|
Enum<E> |
Properties
| Improve this Doc View SourceMembers
Gets declared enum members.
Declaration
public static IReadOnlyList<Enum<E>> Members { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Enum<E>> |
Name
Represents name of the enum member.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String |
UnderlyingType
Gets the underlying type of the specified enumeration.
Declaration
public static Type UnderlyingType { get; }
Property Value
Type | Description |
---|---|
Type |
UnderlyingTypeCode
Gets code of the underlying primitive type.
Declaration
public static TypeCode UnderlyingTypeCode { get; }
Property Value
Type | Description |
---|---|
TypeCode |
Value
Represents value of the enum member.
Declaration
public E Value { get; }
Property Value
Type | Description |
---|---|
E |
Methods
| Improve this Doc View SourceCompareTo(E)
Compares this enum value with other.
Declaration
public int CompareTo(E other)
Parameters
Type | Name | Description |
---|---|---|
E | other | Other value to compare. |
Returns
Type | Description |
---|---|
Int32 | Comparison result. |
Equals(E)
Determines whether this value equals to the other enum value.
Declaration
public bool Equals(E other)
Parameters
Type | Name | Description |
---|---|---|
E | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | Equality check result. |
Equals(Enum<E>)
Determines whether two enum members are equal.
Declaration
public bool Equals(Enum<E> other)
Parameters
Type | Name | Description |
---|---|---|
Enum<E> | other | Other member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is the same as other; otherwise, false. |
Equals(Object)
Determines whether this value equals to the other enum value.
Declaration
public override bool Equals(object other)
Parameters
Type | Name | Description |
---|---|---|
Object | other | Other value to compare. |
Returns
Type | Description |
---|---|
Boolean | Equality check result. |
GetHashCode()
Gets hash code of the enum member.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code of the enum member. |
GetMember(E)
Gets enum member by its value.
Declaration
public static Enum<E> GetMember(E value)
Parameters
Type | Name | Description |
---|---|---|
E | value | The enum value. |
Returns
Type | Description |
---|---|
Enum<E> | The enum member. |
GetMember(String)
Gets enum member by its case-sensitive name.
Declaration
public static Enum<E> GetMember(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the enum value. |
Returns
Type | Description |
---|---|
Enum<E> | The enum member. |
HasFlag(E)
Determines whether one or more bit fields are set in the current instance.
Declaration
public bool HasFlag(E flag)
Parameters
Type | Name | Description |
---|---|---|
E | flag | An enumeration value. |
Returns
Type | Description |
---|---|
Boolean |
IsDefined(E)
Returns an indication whether a constant with a specified value exists in a enumeration of type E
.
Declaration
public static bool IsDefined(E value)
Parameters
Type | Name | Description |
---|---|---|
E | value | The value of a constant in |
Returns
Type | Description |
---|---|
Boolean | true if a constant in |
IsDefined(String)
Returns an indication whether a constant with a specified name exists in a enumeration of type E
.
Declaration
public static bool IsDefined(string name)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of a constant in |
Returns
Type | Description |
---|---|
Boolean | true if a constant in |
ToString()
Returns textual representation of the enum value.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | The textual representation of the enum value. |
TryGetMember(E, out Enum<E>)
Attempts to retrieve enum member which constant value is equal to the given value.
Declaration
public static bool TryGetMember(E value, out Enum<E> member)
Parameters
Type | Name | Description |
---|---|---|
E | value | Enum value. |
Enum<E> | member | Enum member which constant value is equal to |
Returns
Type | Description |
---|---|
Boolean | true, if there are member declared the given constant value exist; otherwise, false. |
TryGetMember(String, out Enum<E>)
Attempts to retrieve enum member which name is equal to the given value.
Declaration
public static bool TryGetMember(string name, out Enum<E> member)
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of a constant. |
Enum<E> | member | Enum member which name is equal to |
Returns
Type | Description |
---|---|
Boolean | true, if there are member declared the given constant value exist; otherwise, false. |
Operators
| Improve this Doc View SourceEquality(Enum<E>, Enum<E>)
Determines whether two enum members are equal.
Declaration
public static bool operator ==(Enum<E> first, Enum<E> second)
Parameters
Type | Name | Description |
---|---|---|
Enum<E> | first | The first member to compare. |
Enum<E> | second | The second member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is the same as other; otherwise, false. |
Implicit(Enum<E> to E)
Converts typed enum wrapper into actual enum value.
Declaration
public static implicit operator E(in Enum<E> en)
Parameters
Type | Name | Description |
---|---|---|
Enum<E> | en | Enum wrapper to convert. |
Returns
Type | Description |
---|---|
E |
Inequality(Enum<E>, Enum<E>)
Determines whether two enum members are not equal.
Declaration
public static bool operator !=(Enum<E> first, Enum<E> second)
Parameters
Type | Name | Description |
---|---|---|
Enum<E> | first | The first member to compare. |
Enum<E> | second | The second member to compare. |
Returns
Type | Description |
---|---|
Boolean | true if this enum member is not the same as other; otherwise, false. |