using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LambdaCode
{
class Program
{
public delegate double Arithmetic(double val);
static void Main(string[] args)
{
Arithmetic obj = x => ++x;
Console.WriteLine(obj(5));
obj = x => --x;
Console.WriteLine(obj(6));
obj = x => x / 2;
Console.WriteLine(obj(7));
obj = x => x * 2;
Console.WriteLine(obj(8));
Console.WriteLine("The even numbers are:");
List<int> numbers = new List<int> {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
var evenlist = numbers.Where(x => x % 2 == 0).ToList();
foreach(int no in evenlist)
{
Console.WriteLine(no);
}
Console.WriteLine("The no between 2 and 5");
var rangebetween = numbers.Where(a=>a>=2&&a<=5).ToList();
foreach (int no in rangebetween)
{
Console.WriteLine(no);
}
Console.ReadKey();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LambdaCode
{
class Program
{
public delegate double Arithmetic(double val);
static void Main(string[] args)
{
Arithmetic obj = x => ++x;
Console.WriteLine(obj(5));
obj = x => --x;
Console.WriteLine(obj(6));
obj = x => x / 2;
Console.WriteLine(obj(7));
obj = x => x * 2;
Console.WriteLine(obj(8));
Console.WriteLine("The even numbers are:");
List<int> numbers = new List<int> {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
var evenlist = numbers.Where(x => x % 2 == 0).ToList();
foreach(int no in evenlist)
{
Console.WriteLine(no);
}
Console.WriteLine("The no between 2 and 5");
var rangebetween = numbers.Where(a=>a>=2&&a<=5).ToList();
foreach (int no in rangebetween)
{
Console.WriteLine(no);
}
Console.ReadKey();
}
}
}
Comments
Post a Comment