collection(IEnumerable) of a particular type as parameter for a function

  • Thread starter Thread starter parez
  • Start date Start date
P

parez

Hi All,


is there anyway i can take collection(IEnumerable) of a particular
type as a paramter for a function.
Thanks in advance.
 
do you mean to say, that you need to be sure the collection can only
be passed to the function if it's of a the type ZZZ (the one you
need) ??
 
do you mean to say, that you need to be sure the collection can only
be passed to the function if it's of a the type ZZZ (the one you
need) ??

well. it could be any kind of collection ..but it should only contain
the type zzz
 
I don'T really get what you're trying to accomplish.... but... if you
want to be sure that the collection is containing objects of a certain
type only, then you could make a validation at the beginning of your
function like this

Private Function getValue(byref coll as Collection) As Boolean
Dim value As Boolean = true
For Each obj As Object In coll
If Not TypeOf(obj) Is GetType(ZZZ) Then
MsgBox("Collection containing objects different from type ZZZ")
value = false
End If
Next
return value
End Function
 
Back
Top