i’m encountering the following problem. I recently activated ‘Option Strict On’ and now I get an error in my LINQ query. From e As TEnum returns the following error:
Option Strict On disallows implicit conversions from ‘Object’ to ‘TEnum’
Does anyone know how to solve this?
Public Module SelectItemPandEnumExtension
<System.Runtime.CompilerServices.Extension()> _
Public Function ToSelectListEnum(Of TEnum)(enumObj As TEnum) As SelectList
Dim values = From e As TEnum In [Enum].GetValues(GetType(TEnum))
Select New With {.Id = e, .Name = e.ToString()}
Return New SelectList(CType(values, Collections.IEnumerable), "Id", "Name", enumObj)
End Function
End Module
I had to remove the
As TEnum.