0% found this document useful (0 votes)
5 views1 page

Program Cs

The document is a C# program that initializes a list of integers and performs various operations on it, including printing the numbers, calculating their squares, and finding even numbers. It also defines two functions to calculate the square and cube of a given number, demonstrating the use of lambda expressions. The program outputs the results of these operations to the console.

Uploaded by

chloekhoury2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Program Cs

The document is a C# program that initializes a list of integers and performs various operations on it, including printing the numbers, calculating their squares, and finding even numbers. It also defines two functions to calculate the square and cube of a given number, demonstrating the use of lambda expressions. The program outputs the results of these operations to the console.

Uploaded by

chloekhoury2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

namespace testapp01

{
internal class Program
{
static void Main(string[] args)
{
List<int> listofnumbers = new List<int>();
listofnumbers.Add(1);
listofnumbers.Add(2);
listofnumbers.Add(3);
listofnumbers.Add(4);
listofnumbers.Add(5);
listofnumbers.Add(6);
foreach (int i in listofnumbers)
{
Console.WriteLine(i);
}
var squaroflist = listofnumbers.Select(x => x * x);
foreach (int j in squaroflist) {
Console.WriteLine(j);
}
var evenlist = listofnumbers.FindAll(x => x % 2 == 0);
foreach (int i in evenlist)
{
Console.WriteLine(i);
}
Func<double, double> Squareofanumber = x => x * x;
Console.WriteLine(
"Square of 3.2 " + Squareofanumber(3.2)
);
Func<double, double> Cubeofanumber = x => x * x * x;
Console.WriteLine(
"Cube of 6.5 " + Cubeofanumber(6.5)
);
}
}
}

You might also like