Just a random passing of information because I found the research for this to be complicated; so I figured I would save some other developers the trouble of figureing out how.
Even though it's possible to derive; I would be inclined to recommend that Microsoft make this into a .ToArray function for enummerations just to make it easier to do because I use this style of coding commonly.
I usually always use enummerations as a pass ID of some type with a calculated value using the n^2 notation to calculate the return values. It's easy to derive with squareroots what values are derived from a sum; but most of the time I use the Identifier String to denote a combo box drop down list view. I think this is fairly routine for most developers; since in all my coding or rework I have seen it used commonly by other developers also.
Anyway, I wanted to do some sort of comparisson array of strings to fill the combobox using the *.Items.AddRange() function and it requires an array pass (this typically shrinks the code down considerably) and if you want to mix and match arrays in segments it's easier. So here is the code; for doing so I am assuming that other developers use an "AddToArray" type function like me; if not you have to write the function or just replace the code with the actual adding to array.
Good luck, and I hope this limits your research time; if I had this it would have saved me a few hours.
Even though it's possible to derive; I would be inclined to recommend that Microsoft make this into a .ToArray function for enummerations just to make it easier to do because I use this style of coding commonly.
I usually always use enummerations as a pass ID of some type with a calculated value using the n^2 notation to calculate the return values. It's easy to derive with squareroots what values are derived from a sum; but most of the time I use the Identifier String to denote a combo box drop down list view. I think this is fairly routine for most developers; since in all my coding or rework I have seen it used commonly by other developers also.
Anyway, I wanted to do some sort of comparisson array of strings to fill the combobox using the *.Items.AddRange() function and it requires an array pass (this typically shrinks the code down considerably) and if you want to mix and match arrays in segments it's easier. So here is the code; for doing so I am assuming that other developers use an "AddToArray" type function like me; if not you have to write the function or just replace the code with the actual adding to array.
Good luck, and I hope this limits your research time; if I had this it would have saved me a few hours.
VB.NET:
''' <summary>
''' Convert an enummeration to an array.
''' </summary>
''' <param name="ConvertTo">Convert to return type.</param>
Public Shared Function EnumToArray(Of ArbitraryEnum)(ByVal ConvertTo As ConvertEnumToArrayOf)
Dim returnValue As Object = Nothing
Select Case ConvertTo
Case ConvertEnumToArrayOf.AsString
Dim Values() As String = Nothing
For Each Enumeration In System.Enum.GetNames(GetType(ArbitraryEnum))
AddToArray(Values, Enumeration)
Next
Return Values
Case ConvertEnumToArrayOf.AsInteger
Dim Values() As Integer = Nothing
For Each Enumeration In System.Enum.GetValues(GetType(ArbitraryEnum))
AddToArray(Values, Enumeration)
Next
Return Values
Case ConvertEnumToArrayOf.AsEnumeration
Dim Values() As Object = Nothing
For Each Enumeration In System.Enum.GetValues(GetType(ArbitraryEnum))
AddToArray(Values, Enumeration)
Next
Return Values
End Select
Return returnValue
End Function