Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What part of the C# language is .ForEach()?

If I'm explaining the following ForEach feature to someone, is it accurate to say that #2 is the "LINQ foreach approach" or is it simply a "List<T> extension method" that is not officially associated with LINQ?

var youngCustomers = from c in customers
                     where c.Age < 30
                     select c;

//1. traditional foreach approach
foreach (var c in youngCustomers)
{
    Console.WriteLine(c.Display());
}

//2. LINQ foreach approach?
youngCustomers.ToList().ForEach(c => Console.WriteLine(c.Display()));
like image 535
Edward Tanguay Avatar asked Jul 19 '10 13:07

Edward Tanguay


People also ask

What is Medicare Part C used for?

Medicare Part C covers the inpatient care typically covered by Medicare Part A. If you are a Medicare Part C subscriber and are admitted to the hospital, your Medicare Advantage plan must cover a semi-private room, general nursing care, meals, hospital supplies, and medications administered as part of inpatient care.

Is Medicare Part C part of Medicare?

A Medicare Advantage Plan (like an HMO or PPO) is another Medicare health plan choice you may have as part of Medicare. Medicare Advantage Plans, sometimes called “Part C” or “MA Plans,” are offered by private companies approved by Medicare.

Is Medicare Part C the same as Medicare Advantage?

A Medicare Advantage is another way to get your Medicare Part A and Part B coverage. Medicare Advantage Plans, sometimes called "Part C" or "MA Plans," are offered by Medicare-approved private companies that must follow rules set by Medicare.

Is Medicare Part C required?

You don't need to buy a Medicare Part C plan. It's an alternative to original Medicare that offers additional items and services. Some of these include prescription drugs, dental, vision, and many others.


1 Answers

it is a normal method of List<T> though people often provide their own extension methods for other IEnumerable<T>. LINQ does not provide a ForEach extension due to its design goals of being functional/ working with immutable types, ForEach is an inherently side effect/imperative operation.

like image 65
jk. Avatar answered Sep 19 '22 07:09

jk.