Tech Study

Write a program in C# to find the number of an array and the square of each number in LINQ Query

Introduction

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
using System.Linq;
using System.Collections.Generic;
 
class LinqExercise
{
    static void Main(string[] args)
    {
 
        var arr = new[] { 6,7,8,9 };
 
        var sqaure = from int Number in arr
                   let SqrNo = Number * Number                   
                     select new { Number, SqrNo };
 
        foreach (var a in sqaure)
            Console.WriteLine(a);
 
        Console.ReadLine();
    }
}

Result

Write a program in C# to find the number of an array and the square of each number in LINQ Query
Write a program in C# to find the number of an array and the square of each number in LINQ Query

TaggedWrite a program in C# to find the number of an array and the square of each number in LINQ Query

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more