linq foreach csharp

Code Example - linq foreach csharp

                
                        sequence.Where(x => x.Name.ToString().Equals("Apple"))
    .ToList()
    .ForEach( x =>
     {
       if(someCondition)
       {
         // Do some stuff here.
       }  
     });
                    
                
 

foreach csharp linq example

                        
                                items.ToList().ForEach(i => i.DoStuff());
                            
                        
 

csharp linq foreach example

                        
                                myList.Where(l => l.Name.ToSting().Equals("Fortune")).ToList().ForEach(x => x.salary += deductions);
                            
                        
 

convert foreach to linq csharp

                        
                                foreach (string field in fieldsList)
            {
                if (retrievedOrderLine.Attributes.Contains(field))
                {
                    orderLine[field] = retrievedOrderLine[field];
                }
            }