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

  • Home
  • SEARCH
  • 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 6005265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:22:29+00:00 2026-05-23T01:22:29+00:00

Suppose I have the following code: List<SomeObject> someObjects = ReturnListWithThousandsOfObjects(); foreach(SomeObject someobject in someObjects)

  • 0

Suppose I have the following code:

List<SomeObject> someObjects = ReturnListWithThousandsOfObjects();

foreach(SomeObject someobject in someObjects)
{
   DoSomething.With(someObject);
}

And also suppose that after a minute of running I put a breakpoint on DoSomething.With(someObject);.

The debugger breaks for me just fine. But now I want to know what point am I at in my iteration of the list (assume the list is unordered/has no key).

Is there a way for the debugger to say “the foreach has run 532 of 2321 iterations”?

  • 1 1 Answer
  • 0 Views
  • 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-23T01:22:30+00:00Added an answer on May 23, 2026 at 1:22 am

    As a debugging one off isn’t there an indexof method?

    i.e.

    quickwatch – someObjects.indexOf(someObject);

    Added – Sorry if a bit brief.

    As pointed out by Guffa this will work best if the values are unique or the default equality comparer EqualityComparer function uses a unique value (such as a custom GetHashCode/Equals overload).

        public class ATest
        {
            public int number { get; set; }
            public int boo { get; set; }
            public ATest()
            {
    
            }
        }
    
        protected void Go()
        {
            List<ATest> list = new List<ATest>();
    
            foreach(var i in Enumerable.Range(0,30)) {
                foreach(var j in Enumerable.Range(0,100)) {
                    list.Add(new ATest() { number = i, boo = j });                  
                }
            }
    
            var o =0; //only for proving concept.
            foreach (ATest aTest in list)
            {               
                DoSomthing(aTest);
                //proof that this does work in this example.
                o++;
                System.Diagnostics.Debug.Assert(o == list.IndexOf(aTest));
            }
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following arrays: List<int[]> numbers = new List<int[]>(); numbers.Add(new int[] {
Suppose you have a list of values x <- list(a=c(1,2,3), b = c(2,3,4), c=c(4,5,6))
I have the following code, which is supposed to add a shared_ptr instance to
I have the following code: # app/models/part.rb class Part < ActiveRecord::Base has_many :lots #
I have implemented in my app the mitigation to CSRF attacks following the informations
I have an Owner Drawn List Box in an external application ( America Online
We have inherited a very convolved project (500kloc) with a lot of preprocessor conditional
I've run into the following problem: My Delphi7 program runs smoothly on most computers
Technology: Java 1.5 or 1.6 Hibernate 3.4 To avoid update of column name on
I think it's more difficult to ask than answering the question. I wanna ask

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.