I need to get three objects from a function, my instinct is to create a new type to return three links. Or, if the links were of the same type, I could use an array. However, pass-by-ref is simpler:
private void Mutate_AddNode_GetGenes(ref NeuronGene newNeuronGene, ref ConnectionGene newConnectionGene1, ref ConnectionGene newConnectionGene2)
{
}
Obviously, there is nothing wrong with that, but I hesitate to use this approach, mainly I think for reasons of aesthetics and psychology. Are there any good reasons to use one of these approaches for others? There may be a performance issue when creating additional wrapper objects or pushing parameters onto the stack. Please note that in my particular case this is processor code. CPU cycles matter.
Is there a more elegant C # 2 approach to C # 3?
Thanks.
source
share