+ 2
Display all even elements. Best Practice.
If I would like to print every second element in an array what is the best practice? An if statement in a foreach or a for loop with i+=2? Does the compiler optimize if i use foreach? Is there a better way maybe?
1 Réponse
+ 6
You may use foreach for this purpose. Check out the comparison among those two,
https://www.dotnetperls.com/for-foreach