EnumExtensionsGetEnumFromDescriptionT Method |
Namespace:
Xcalibur.Extensions
Assembly:
Xcalibur.Extensions (in Xcalibur.Extensions.dll) Version: 1.0.4.0 (1.0.0.0)
Syntax public static T GetEnumFromDescription<T>(
string value
)
where T : struct, new(), IConvertible
Public Shared Function GetEnumFromDescription(Of T As {Structure, New, IConvertible}) (
value As String
) As T
public:
generic<typename T>
where T : value class, gcnew(), IConvertible
static T GetEnumFromDescription(
String^ value
)
static member GetEnumFromDescription :
value : string -> 'T when 'T : struct, new() and IConvertible
Parameters
- value
- Type: SystemString
string representing the enum's description
Type Parameters
- T
- The type of Enum
Return Value
Type:
TExceptions Examples 1
2
3
4public enum ThreadStateType
5{
6 [Description("Initialized")]
7 Started = 0,
8
9 [Description("Ready")]
10 Waiting = 1,
11
12 [Description("Running")]
13 Processor = 2,
14
15 [Description("Standby")]
16 PreProcessor = 3,
17
18 [Description("Terminated")]
19 Ended = 4,
20
21 [Description("Wait")]
22 NotReady = 5,
23
24 [Description("Transition")]
25 WaitingForResource = 6,
26
27 [Description("Unknown")]
28 UndeterminedState = 7
29}
30
31
32
33
34public void GetEnumFromDescriptionTest()
35{
36
37 ThreadStateType myType = EnumExtensions.GetEnumFromDescription<ThreadStateType>("Running");
38
39
40}
See Also