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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:00:00+00:00 2026-05-23T18:00:00+00:00

I have a data structure as follows: I have a list of objects with

  • 0

I have a data structure as follows: I have a list of objects with properties that i want to search for and then when i have found all the objects matching my search query, i want to update another property for all the found objects. Here is an example of the object’s properties:

Name: Sean Aston
City: Toronto
Eye Color: Blue
Warnings: 4

Name: Cole Anderson
City: New York City
Eye Color: Black
Warnings: 1

Name: Polly Smith
City: Toronto
Eye Color: Blue
Warnings: 3

My search woluld be select all those objects in the list whose properties eye color is blue and city is toronto. It should return me objects one and three. Then i should be able to update the warnings property of the first and third object to increment by 1.

How can i achieve this?
Thanks in advance.

  • 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-23T18:00:01+00:00Added an answer on May 23, 2026 at 6:00 pm

    To match your exact request would look like this:

    foreach (var item in MyObjectList.Where(o => o.EyeColor == "Blue" && o.City == "Toronto"))
    {
        item.Warnings ++;
    }
    

    But I suspect the criteria is entirely determined by the user, and so you don’t know what you’re looking for at compile time like this. In that case:

    var search = (IEnumerable<MyObject>)MyObjectList;
    
    if (!string.IsNullOrEmpty(txtCity.Text))
    {
        search = search.Where(o => o.City == txtCity.Text);
    }
    
    if (!string.IsNullOrEmpty(txtEyeColor.Text))
    {
        search = search.Where(o => o.EyeColor == txtEyeColor.Text);
    }
    
    // similar checks for name or warning level could go here
    
    foreach(var item in search) {item.Warnings++;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data.frame as follows: dat <- structure(list(id = 1:4, date = structure(list(sec
I'm looking for a data structure that has the following properties. Stores a list
I have a python data-structure as follows: A = [{'abc': 'kjkjl'},{'abc': 'hjhjh'},{'abc': '78787'}] How
I have a data structure that represents C# code like this: class Namespace: string
I have a data structure of key value pairs and I want to implement
I want to design a data structure with the following properties: Accessible as a
i have data structure i am passing this from server to client using data
I need to have data structure, each element in which is accessible by pair
I have a data structure which uses composite ids (Which I dont wish to
I have a data structure defined as struct myDataStruct { int32_t header; int16_t data[8];

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.