Hi all,
Essentially i want to have a generic function which accepts a LINQ annonymous list and returns an array back. I was hoping to use generics but i just can seem to get it to work.
hopefully the example below helps
say i have a person object with id, fname, lname and dob. i have a generic class with contains a list of objects.
i return an array of persons back
my code snippet wule be something like
dim v = from p in persons.. select p.fname,p.lname
i now have an annonymous type from system.collections.generic.ineumerable(of t)
to bind this to a grid i would have to iterate and add to an array e.g.
dim ar() as array
for each x in v ar.add(x) next
grid.datasource = ar
i dont want to do the iteration continually as i might have different objects
i would like a function which does something like below:
function getArrayList(of T)(dim x as T) as array()
dim ar() as array
for each x in t ar.add(x) next
return ar
end
hope that clairifies. how can i get a generic function with accepts an annonymous list of ienumearable and returns an array back. unfortunately, the one i have does not work.
many thanks in advance as any and all pointers/help will be VASTLY appreciated.
regards
azad