-3

When I am writing code, I sometimes wonder which format is faster;

The old fashioned use of an incrementing variable: i

or

A foreach loop?

2

2 Answers 2

2

Neither is "faster" you need to use the right tool for the job, sometimes for is faster sometimes foreach is faster.

"micro optimizations" like you are taking about are so insignificant that you will NEVER recover the time in speed up than you will compared to the amount of extra time you took implementing it.

If your program is slow use a profiler on it and find where the real problem is.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.