G
Guest
Yello,
Quick Q:
If I have a few objects and cast them(?) into an array of a piticular
interface,
would I have boxed the objects? Thus I wouldnt continuously re-box
that type, inturn saving processing time?
eg:
private bird bird1; //Has an IAnimal interface, (no, it does not inherit
animal obj)
private cat cat1; //""
private dog dog1; //""
private IAnimal[] myPets; //(<--will that even work?, I know that obj will
work,
// but I dont want to un-box, and
re-box continuously.)
void main()
{
bird1 = new bird();
cat1 = new cat();
dog1 = new dog();
myPets = new IAnimal[3];
myPets[0] = bird1;
myPets[1] = cat1;
myPets[2] = dog1;
for(int x =0; x < 3; x++)
myPets[x].dispose(true);
}
//(Perhaps disposing my pets might not have been the best choice.
// No, realy, I do like my pets, and dont plan to dispose of them.)
Quick Q:
If I have a few objects and cast them(?) into an array of a piticular
interface,
would I have boxed the objects? Thus I wouldnt continuously re-box
that type, inturn saving processing time?
eg:
private bird bird1; //Has an IAnimal interface, (no, it does not inherit
animal obj)
private cat cat1; //""
private dog dog1; //""
private IAnimal[] myPets; //(<--will that even work?, I know that obj will
work,
// but I dont want to un-box, and
re-box continuously.)
void main()
{
bird1 = new bird();
cat1 = new cat();
dog1 = new dog();
myPets = new IAnimal[3];
myPets[0] = bird1;
myPets[1] = cat1;
myPets[2] = dog1;
for(int x =0; x < 3; x++)
myPets[x].dispose(true);
}
//(Perhaps disposing my pets might not have been the best choice.
// No, realy, I do like my pets, and dont plan to dispose of them.)