Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 877379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:35:53+00:00 2026-05-15T11:35:53+00:00

Logically, one would think that the foreach loop in C# would evaluate in the

  • 0

Logically, one would think that the foreach loop in C# would evaluate in the same order as an incrementing for loop. Experimentally, it does. However, there appears to be no such confirmation on the MSDN site.

Is it simply such an apparent answer that they did not think to include that information on the site? Or is there the possibility that it will behave erratically?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:35:54+00:00Added an answer on May 15, 2026 at 11:35 am

    For arrays (note that System.Array implements IEnumerable), it will access elements in order. For other types (IEnumerable, or having GetEnumerator), it accesses elements in the order provided, through alternating MoveNext and Current calls.

    The standard states (ECMA-334 §13.9.5):

    “The order in which foreach traverses
    the elements of an array, is as
    follows: For single-dimensional arrays
    elements are traversed in increasing
    index order, starting with index 0 and
    ending with index Length – 1. For
    multi-dimensional arrays, elements are
    traversed such that the indices of the
    rightmost dimension are increased
    first, then the next left dimension,
    and so on to the left.”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one revert a remote git repo after a reset done locally? We
I want to bind one data to several controls. Is there some logical control
Rails make It possible to map resources that are logically children of other resources
One of my website pages allows users to save locations that they've visited. They
My gut tells me that putting one format in another is wrong, but I
What would make one table substantially slower than another? Probably easiest to just illustrate:
I have followed the following instructions in setting a git repository locally in one
Given a table of logical resource identifiers (one per row), what is the best
I cant seem to compare two JS files (one edited locally and the latest
I know in C like languages logical operators are evaluated one at a time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.