Is this good programming practice?
The following example code will compile, but I'm wondering if it's considered a good way of doing things generally?
Code:
for(int i = 0; i < selectedElementsFromMyArray; i++)
{
myTemporaryStorage.Add(myArray[selectedElementsFromMyArray[i]]);
}
I want to add a subset of elements from myArray into myTemporaryStorage, the indexes of the elements to be stored are held in selectedElementsFromMyArray.
Good progarmming or bad, please let me know. Thanks.
Re: Is this good programming practice?
I would consider creating a second array containing only the elements of interest and then calling the AddRange method of the collection.
Re: Is this good programming practice?
Thanks jmcilhinney, I'll try that.