IanRyder
Well-known member
Hi All,
I saw a Function declaration on the forum this morning which I am not familiar with and am hoping for some guidance on its usage.
This is what was posted on the forum:-
Even though this declaration is unfamiliar to me I was easily able to convert this declaration into something which I could easily understand. Being:-
As to my questions:-
1) Am I right in thinking that the (Of T) in the first declaration is defining a generic list of objects that can be returned to the calling routine?
2) With Option Strict On, how is it that Visual Studio does not throw up it's usual type conversion issues when (Of T) is not defined as a specific type? I guess I am missing something about (Of T)?
3) Finally, are there any advantages in defining a Function declaration as shown in the first example as apposed to what is show in the second example or is this just a case of preference?
Thanks for any help you can provide.
Cheers,
Ian
I saw a Function declaration on the forum this morning which I am not familiar with and am hoping for some guidance on its usage.
This is what was posted on the forum:-
VB.NET:
Private Function FunctionName(Of T)(list As IEnumerable(Of T), count As Integer) As T()
'do work
End Function
Even though this declaration is unfamiliar to me I was easily able to convert this declaration into something which I could easily understand. Being:-
VB.NET:
Private Function FunctionName(list() As Integer, count As Integer) As Integer()
'do work
End Function
As to my questions:-
1) Am I right in thinking that the (Of T) in the first declaration is defining a generic list of objects that can be returned to the calling routine?
2) With Option Strict On, how is it that Visual Studio does not throw up it's usual type conversion issues when (Of T) is not defined as a specific type? I guess I am missing something about (Of T)?
3) Finally, are there any advantages in defining a Function declaration as shown in the first example as apposed to what is show in the second example or is this just a case of preference?
Thanks for any help you can provide.
Cheers,
Ian
Last edited: