2
Reply

Why only the first parameter in the definition of VB.NET Generics uses the 'Of' keyword ?

Ask a question
Goofy Giraffe

Goofy Giraffe

12y
2.2k
1


For example I have here the  the full code that LINQ uses for the Enumerable.Select() method :


<System.Runtime.CompilerServices.Extension()> _
Public Shared Function [Select](Of TSource, TResult)(
ByVal source As IEnumerable(Of TSource),
ByVal selector As Func(Of TSource, TResult)
) As IEnumerable(Of TResult)
If source Is Nothing Then
Throw New ArgumentNullException("source")
End If
If selector Is Nothing Then
Throw New ArgumentNullException("selector")
End If
Return SelectIterator(Of TSource, TResult)(source, selector)
End Function



I understand the 'Of' keyword denotes a generic type parameter, but why is this keyword not used for the TResult parameter as well in the  'Public Shared Function [Select](Of TSource, TResult)' from above ?



Answers (2)