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 71127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:50:20+00:00 2026-05-10T19:50:20+00:00

Is it possible to iterate collection and list only filtered object information while debugging

  • 0

Is it possible to iterate collection and list only filtered object information while debugging in Visual Studio? I’d use Immediate window for that, but although it allows to execute methods on objects, it seems not to allow execute custom loop statements.

Simplest example in ASP.NET:

this.Page.Validate(); if (!this.Page.IsValid()) {   // breakpoint here } 

How can we iterate Page.Validators collection and find those which are invalid + output their information at that breakpoint? (this is not the main question, it’s just a sample)

If it’s not possible to do it straight forward, do you have any workarounds for this? Workarounds which would not involve code modification, just writing code in Immediate window or some Watch expression.

While googling I’ve found just one workaround quoted here (although could not find the original):

‘Add a debug method to your code that does something like iterate through all the objects in a collection. Then you can call that method from the immediate window while in debug mode and it will enumerate various things for you. Think of it like a command-line-debugger-helper. You can write as many of those as you like.’

But it’s still a workaround. I image it should be doable without too much hacking and more importantly without modifying code. Of course it should be possible to do some kind of collection transformations in one statement.

And let’s stick to non-generic collections. Also Immediate window seems not to accept lambda expressions (got an error when tried: ‘Expression cannot contain lambda expressions’)

  • 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. 2026-05-10T19:50:21+00:00Added an answer on May 10, 2026 at 7:50 pm

    You could try using the immediate window and a LINQ-to-objects call.

    Contrived example:

     pages.Where((x) =>  {     if (x.IsValid)     {         Debugger.Break();         return true;     }     return false;  }); 

    Update: Apparently, this won’t work as immediate window doesn’t allow lambdas. However, if you implement the lambda as a debug only method you could do this.

    [Conditional('DEBUG')] static bool BreakpointPredicate(YourItemType x) {     if (x.IsValid)     {         Debugger.Break()         return true;     }     return false; } 

    And then just put a call to Where in the immediate window:

    pages.Where(BreakPointPredicate); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer As bendewey says, XmlWriterSettings is what you need - e.g.… May 11, 2026 at 12:51 pm
  • added an answer Something like: SELECT COUNT(*) AS `Rows`, UserID FROM `postings` GROUP… May 11, 2026 at 12:51 pm
  • added an answer I hope this is clear. Basically I'm just asking if… May 11, 2026 at 12:51 pm

Related Questions

Is it possible to configure xampp to serve up a file outside of the
Is it possible to use a flash document embedded in HTML as a link?
Is it possible to access an element on a Master page from the page
Is it possible to somehow use a .bat file to script the schema and/or
A coworker used a for loop to iterate a List in some C# code
I am working on a basic Struts based application that is experience major spikes
I have a fairly deep object graph (5-6 nodes), and as I traverse portions
I have a collection of polymorphic objects, all derived from my Animal class: Cat,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.