Show / Hide Table of Contents

Class EnumEx

Class containing some extension methods for System.Enum.

Inheritance
System.Object
EnumEx
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace:Extend
Assembly:Extend.dll
Syntax
public static class EnumEx

Methods

| Improve this Doc View Source

GetStringValues<T>()

Gets the values of the specified enumeration as strings.

Declaration
public static IEnumerable<string> GetStringValues<T>()where T : struct
Returns
Type Description
System.Collections.Generic.IEnumerable<T><System.String>

All values of the specified enumeration as strings.

Type Parameters
Name Description
T The type of the enumeration.
Exceptions
Type Condition
System.ArgumentException

T must be an enumerated type.

| Improve this Doc View Source

GetValueAndStringValue<T>()

Gets a dictionary containing the string value for each value of the enumeration of the given type.

Declaration
public static IDictionary<T, string> GetValueAndStringValue<T>()where T : struct
Returns
Type Description
System.Collections.Generic.IDictionary<TKey, TValue><T, System.String>

Returns a key value pair for each value of the specified enumeration type.

Type Parameters
Name Description
T The type of the enumeration.
Exceptions
Type Condition
System.ArgumentException

T must be an enumerated type.

| Improve this Doc View Source

GetValues(Type)

Gets the values of the specified enumeration.

Declaration
public static IEnumerable GetValues(Type type)
Parameters
Type Name Description
System.Type type

The type of the enumeration.

Returns
Type Description
System.Collections.IEnumerable

All values of the specified enumeration.

Remarks

How to cast returned values: values.Cast{Object}(); values.Select( x => Convert.ChangeType( x, type ) );

Exceptions
Type Condition
System.ArgumentNullException

type can not be null.

System.ArgumentException

T must be an enumerated type.

| Improve this Doc View Source

GetValues<T>()

Gets the values of the specified enumeration.

Declaration
public static IEnumerable<T> GetValues<T>()where T : struct
Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>

All values of the specified enumeration.

Type Parameters
Name Description
T The type of the enumeration.
Exceptions
Type Condition
System.ArgumentException

T must be an enumerated type.

| Improve this Doc View Source

GetValuesExpect(Type, Object[])

Gets all values of the specified enumeration type, expect the specified values.

Declaration
public static IEnumerable GetValuesExpect(Type type, params object[] exceptions)
Parameters
Type Name Description
System.Type type

The type of the enumeration.

System.Object[] exceptions

The values to exclude from the result.

Returns
Type Description
System.Collections.IEnumerable

Returns all values of the specified enumeration type, expect the specified values.

Remarks

How to cast returned values: values.Cast{Object}(); values.Select( x => Convert.ChangeType( x, type ) );

Exceptions
Type Condition
System.ArgumentException

T must be an enumerated type.

| Improve this Doc View Source

GetValuesExpect<T>(T[])

Gets all values of the specified enumeration type, expect the specified values.

Declaration
public static IEnumerable<T> GetValuesExpect<T>(params T[] exceptions)where T : struct
Parameters
Type Name Description
T[] exceptions

The values to exclude from the result.

Returns
Type Description
System.Collections.Generic.IEnumerable<T><T>

Returns all values of the specified enumeration type, expect the specified values.

Type Parameters
Name Description
T The type of the enumeration.
Exceptions
Type Condition
System.ArgumentException

T must be an enumerated type.

  • Improve this Doc
  • View Source
Back to top Copyright © 2015-2016 Microsoft
Generated by DocFX