G
Guest
hello all,
I want to create a function that returns the first element of the Array
that is input to it. However, the Input Array can be an Array of points,
double, or anyother type, which means the return type of the function depends
on the type of the objects the Input array holds.
I can have the return type as Object, but it has problems like late binding
and more importantly the client has to always Cast it. For example.
class myclass
public shared function getFirstElement(arr as Array) as Object
return arr(1)
end function
end class
//client code
imports myclass.getFirstElement
dim arr() as point = {point(1,2),point(3,4)....}
dim firstPoint as point
firstPoint = directcast(getfirstElement(arr),point)
Has someone got a better solution or another way, so that the last line of
the code is
firstPoint = getfirstElement(arr)
Thanks in Advance.
nafri
I want to create a function that returns the first element of the Array
that is input to it. However, the Input Array can be an Array of points,
double, or anyother type, which means the return type of the function depends
on the type of the objects the Input array holds.
I can have the return type as Object, but it has problems like late binding
and more importantly the client has to always Cast it. For example.
class myclass
public shared function getFirstElement(arr as Array) as Object
return arr(1)
end function
end class
//client code
imports myclass.getFirstElement
dim arr() as point = {point(1,2),point(3,4)....}
dim firstPoint as point
firstPoint = directcast(getfirstElement(arr),point)
Has someone got a better solution or another way, so that the last line of
the code is
firstPoint = getfirstElement(arr)
Thanks in Advance.
nafri