C# LINQ - How to update an object

Hi..
I have a collection of customers   -   List<Customers>

The Customer object has a  VIP property

What is the syntax to update the Customer who's name is 'SMITH' with the VIP flag = true;

How do I  select on the List, Find 'Smith' and change his flag?
LVL 1
JElsterAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
käµfm³d 👽Connect With a Mentor Commented:
You should be able to do something like this:
List<Customers> someList = new List<Customers>() { /* assume it's initialized */ };

var smiths = from cust in someList
             where cust.Name.ToUpper() == "SMITH"
             select cust;

foreach (var smith in smiths)
{
    smith.VIP = true;
}

Open in new window

0
All Courses

From novice to tech pro — start learning today.