Monday, August 08, 2011

Func Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Func Add = (x, y) => x + y;
Func Minus = (x, y) => x - y;

var richard = Minus;

var jx = OperatreWithFunc(3, 5, Add);
var jx2 = OperatreWithFunc(6, 3,richard);
var jx3 = OperatreWithFunc(3, 53, GetFunc());

}


static int OperatreWithFunc(int x ,int y,Func fun)
{
return fun(x, y);

}

static Func GetFunc()
{
return (a, b) => a + b;
}

}
}

0 Comments:

Post a Comment

<< Home