Reputation: 20474
It is possible in VB.Net to design a readonly property which accepts a type paramater like this pseudo-example?:
Public ReadOnly Property Resources(of T) As IEnumerable(Of T)
Get ' Returns the value of a function.
Return Me.GetResources(Of T)()
End Get
End Property
And also an overload like this?:
Public ReadOnly Property Resources As IEnumerable(Of Object)
Get ' Returns the value of a function.
Return Me.GetResources(Of Object)()
End Get
End Property
PS: The definition of my Class is not generic.
Upvotes: 0
Views: 362
Reputation: 6279
Frustratingly, .Net doesn't allow it. It gives the error we find here:
https://learn.microsoft.com/en-us/dotnet/visual-basic/misc/bc32065
Accessed 10/2017:
A programming element is declared with a type parameter list, but the programming element is not eligible to be a generic type.
Programming elements that are not eligible to be generic include properties, operators, events, and constructors. Declaring any of these elements with a type parameter list results in this error.
Error ID: BC32065
To correct this error
Upvotes: 1