Skip to main content

EnumExtensions

Assembly: ServiceStack.Common.dll
View Source
Declaration
public static class EnumExtensions

Methods

ToDescription(Enum)

Gets the textual description of the enum if it has one. e.g.

<pre><code>enum UserColors { [Description("Bright Red")] BrightRed } UserColors.BrightRed.ToDescription();</code></pre>

View Source
Declaration
public static string ToDescription(this Enum enum)
Returns

System.String

Parameters
TypeName
System.Enumenum

ToKeyValuePairs<T>(IEnumerable<T>)

View Source
Declaration
public static List<KeyValuePair<string, string>> ToKeyValuePairs<T>(this IEnumerable<T> enums)
where T : Enum
Returns

System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<System.String,System.String>>

Parameters
TypeName
System.Collections.Generic.IEnumerable<<T>>enums
Type Parameters
  • T

ToList(Enum)

View Source
Declaration
public static List<string> ToList(this Enum enum)
Returns

System.Collections.Generic.List<System.String>

Parameters
TypeName
System.Enumenum

GetTypeCode(Enum)

View Source
Declaration
public static TypeCode GetTypeCode(this Enum enum)
Returns

System.TypeCode

Parameters
TypeName
System.Enumenum

Has<T>(Enum, T)

View Source
Declaration
public static bool Has<T>(this Enum enum, T value)
Returns

System.Boolean

Parameters
TypeName
System.Enumenum
<T>value
Type Parameters
  • T

Is<T>(Enum, T)

View Source
Declaration
public static bool Is<T>(this Enum enum, T value)
Returns

System.Boolean

Parameters
TypeName
System.Enumenum
<T>value
Type Parameters
  • T

Add<T>(Enum, T)

View Source
Declaration
public static T Add<T>(this Enum enum, T value)
Returns

<T>

Parameters
TypeName
System.Enumenum
<T>value
Type Parameters
  • T

Remove<T>(Enum, T)

View Source
Declaration
public static T Remove<T>(this Enum enum, T value)
Returns

<T>

Parameters
TypeName
System.Enumenum
<T>value
Type Parameters
  • T