C# – First steps with C# and .NET – part 058.

You can find some examples on my website using Linq, but today I will show the most simple example using this feature.
First, you need to take a look at the documentation page and read how this works.
This feature uses a query using three distinct steps of a LINQ query operation:

  • Obtain the data source
  • Create the query
  • Execute the query

I create a folder named LinqExample001 and I use this command to create a console application:

You don’t need to use install with dotnet because this package is set to default.
My source code example for calculating the average for an array comes with these parts: first is the basic calculation and the second one uses the LINQ feature:
This is the source code:

The result of the running code is this:

The data source is the intNumbers.
You can see the LINQ query uses these words: from, in, select to create query.
The execution of the LINK query is the Average function.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.