delegate double Transform(double v);
delegate bool TestInts(int w,int v);
class LambdaExpression
{
static void Main(string[] args)
{
Transform reciprocal = n => 1.0 / n;
Console.WriteLine("The reciprocal of 4 is "+reciprocal(4.0));
Console.WriteLine("the reciprocal of 10 is" + reciprocal(10.0));
Console.WriteLine();
TestInts isFactor=(n,d)=>n%d==0;
Console.WriteLine("Is 3 a factor of 9? "+ isFactor(9,3));
Console.WriteLine("Is 3 a factor of 10? " + isFactor(10, 3));
Console.ReadLine();
}
}
No comments:
Post a Comment