G
Guest
Hello, Newsgroupians:
I have a simple question. I have a function that I want to return an array.
I want the array to be other objects that were instantiated in the function
itself. What's the correct way to return the array? Here's what I would
like to happen...
public object[] MyFunc()
{
object obj1 = SomeOtherFunc1();
object obj2 = SomeOtherFunc2();
object obj3 = SomeOtherFunc3();
return object[3] {obj1, obj2, obj3}; // Of course this is an error
}
But, of course, this doesn't work. I see that creating a new instance of
the array and then assigning the array to object may be inefficient...
object obj1 = SomeOtherFunc1();
object obj2 = SomeOtherFunc2();
object obj3 = SomeOtherFunc3();
object retVal[] = {obj1, obj2, obj3};
return retVal;
Although it may seem inefficient, is this the proper way to return an array
of objects? Is there a better way? Thank you all.
Trecius
I have a simple question. I have a function that I want to return an array.
I want the array to be other objects that were instantiated in the function
itself. What's the correct way to return the array? Here's what I would
like to happen...
public object[] MyFunc()
{
object obj1 = SomeOtherFunc1();
object obj2 = SomeOtherFunc2();
object obj3 = SomeOtherFunc3();
return object[3] {obj1, obj2, obj3}; // Of course this is an error
}
But, of course, this doesn't work. I see that creating a new instance of
the array and then assigning the array to object may be inefficient...
object obj1 = SomeOtherFunc1();
object obj2 = SomeOtherFunc2();
object obj3 = SomeOtherFunc3();
object retVal[] = {obj1, obj2, obj3};
return retVal;
Although it may seem inefficient, is this the proper way to return an array
of objects? Is there a better way? Thank you all.
Trecius