programming-examples/c-sharp/Linq/C# Sharp to find the number of an array and the square of each number which is more than 20.cs
2019-11-15 12:59:38 +01:00

21 lines
739 B
C#

using System;
using System.Linq;
using System.Collections.Generic;
class LinqExercise3
{
static void Main(string[] args)
{
// code from DevCurry.com
var arr1 = new[] { 3, 9, 2, 8, 6, 5 };
Console.Write("\nLINQ : Find the number and its square of an array which is more than 20 : ");
Console.Write("\n------------------------------------------------------------------------\n");
var sqNo = from int Number in arr1
let SqrNo = Number * Number
where SqrNo > 20
select new { Number, SqrNo };
foreach (var a in sqNo)
Console.WriteLine(a);
Console.ReadLine();
}
}