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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:57:40+00:00 2026-05-26T16:57:40+00:00

I have a list and I am trying to find a particular element and

  • 0

I have a list and I am trying to find a particular element and then I want to edit that element.

storage.First(item => item.dirty == true).dirty = false; 

However this doesn’t appear to work since I am guessing First is creating another list and populating it. Is there a function to do what I am I am trying to do?

Here is the data type I am using:

class BaseRegister {
  public bool dirty {set;get;}
}

List <BaseRegister> storage = new List <BaseRegister> ();
  • 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-26T16:57:41+00:00Added an answer on May 26, 2026 at 4:57 pm

    There must be something else wrong with your program which is confusing you. For the avoidance of doubt, here is a complete program using your data types. The output is:

    ---Before---
    True
    False
    True
    ---After---
    False
    False
    True
    

    The code is:

    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Linq;
    using System.Text;
    
    namespace ConsoleApplication40 {
      internal class Program {
        private static List<BaseRegister> storage=new List<BaseRegister>();
    
        private static void Main(string[] args) {
          storage.Add(new BaseRegister {dirty=true});
          storage.Add(new BaseRegister {dirty=false});
          storage.Add(new BaseRegister {dirty=true});
          Dump("---Before---");
          storage.First(item => item.dirty==true).dirty=false;
          Dump("---After---");
        }
    
        private static void Dump(string title) {
          Debug.WriteLine(title);
          foreach(var br in storage) {
            Debug.WriteLine(br.dirty);
          }
        }
    
        private class BaseRegister {
          public bool dirty { set; get; }
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a customers List(of String) on which I am trying to find the
I have a list that I am trying to fill with numbers from a
I have a List of customers that I'm trying to bind to a DataGridView.
I have a list box and i am trying to get currently checked item
I have a list of files that I'm trying to copy and move (using
I have a system that logs information and sometimes find a particular IP address
I am trying to output some Java objects as JSON, they have List properties
I have a list and I am trying to add the data to the
I have a list of ints (hitTableWord) and I am trying to add 1
I have a list view on a page and am trying emulate the toggling

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.